OCS EMBEDDED SCHEME FOR OCAML.

March 03 [Sat], 2012, 20:40
Just discovered the project and added (system “…”) command for system calls.

So I can easier create an utilities with it. After C and even Haskell scheme implementation the project structure looks really good and very understandable. C code is just machine code and there is very complex Haskell project even if syntax is a bit beautifier it’s just unreadable for me, check it yourself on GitHub.

doApply :: Bool -> String -> [String] -> (Maybe String) -> [LispVal]
-> Env -> EEnv -> [LispVal] -> Bool -> IOThrowsError LispVal
doApply trace name params varargs body closure eenv args cflag =
if num params /= num args && varargs == Nothing
then errNumArgs (show body) (num params) args
else do let app = zip params args
ca = head app
prtTrace
envn <- liftIO (bindVars closure app) >>= bindVarArgs varargs

No… for a moment I’m trying to not go deep into haskell, maybe some later but not today. OCamL implementation is there on GitHub too. Here is my new operator system:

let check_exit_status = function
| Unix.WEXITED 0 -> ()
| Unix.WEXITED r -> Printf.eprintf "warning: the process terminated with exit code (%d)\n%!" r
| Unix.WSIGNALED n -> Printf.eprintf "warning: the process was killed by a signal (number: %d)\n%!" n
| Unix.WSTOPPED n -> Printf.eprintf "warning: the process was stopped by a signal (number: %d)\n%!" n
;;
let syscall ?(env=[| |]) cmd =
let ic, oc, ec = Unix.open_process_full cmd env in
let buf1 = Buffer.create 96
and buf2 = Buffer.create 48 in
(try
while true do Buffer.add_channel buf1 ic 1 done
with End_of_file -> ());
(try
while true do Buffer.add_channel buf2 ec 1 done
with End_of_file -> ());
let exit_status = Unix.close_process_full (ic, oc, ec) in
check_exit_status exit_status;
(Buffer.contents buf1,
Buffer.contents buf2)
;;
let system th cc =
function
[| Sstring s |] ->
let obj = syscall s in
let obj1 = Sstring (fst obj) in
let obj2 = Sstring (snd obj) in
let p = get_stdout th
in
print p true obj2; Ocs_port.flush p; cc Sunspec;
print p true obj1; Ocs_port.flush p; cc Sunspec
| _ -> raise (Error "system: bad args")
;;

I can easy understand this code (alike python), improve it and build solutions with it. But sadly I’m using Cygwin for windows yet but I included all libraries right there.

win:
cp cygwin/*.a .
cp cygwin/*.o .
make all
And sure there is easy ebuild for it:

inherit git-2
EAPI=2
DESCRIPTION="A very tiny Scheme implementation with decent speed and native hygienic macros."
EGIT_REPO_URI="git://github.com/nCdy/ocs.git"
HOMEPAGE="http://will.iki.fi/software/ocs/"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
DEPEND="dev-lang/ocaml[ocamlopt]"
RDEPEND="${DEPEND}"
src_install() {
emake DESTDIR="${D}" install || die "Install failed"
}

or you can just add my overlay with using: #layman -a nCdy-overlay
プロフィール
  • プロフィール画像
  • アイコン画像 ニックネーム:nCdy
読者になる
2012年03月
« 前の月  |  次の月 »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
最新コメント
ヤプミー!一覧
P R
カテゴリアーカイブ
月別アーカイブ
http://yaplog.jp/cynede/index1_0.rdf