Re: Ersatz source code and EmuLisp
Hi Christophe, > My question: > Is there any documentation about the building of the Ersatz jar ? > I guess all the keys are in the mkJar file but I'm lost reading it. Right, mkJar is the core of building Ersatz, and it is not documented. Let me try to explain its basic working. As you noticed, it merges the two files "sys.src" and "fun.src" into a final "PicoLisp.java": (out "PicoLisp.java" (in "sys.src" Most of "sys.src" is simply echoed via the (echo "") calls. 'echo' reads the input stream and writes everything to the output stream until it hits the pattern "". (echo "") Now it stops when seeing "", and outputs (prin (glue "," *Version)) then proceeds to (echo "") to generate the 'mkSymbol()' calls. This is done by parsing "fun.src" (let Cnt (read) (in "fun.src" it skips white space and comments (skip "#") and goes all over the file with (loop Now for every code block, it reads the name at the beginning of the line till the first space (let Name (till " " T) and outputs a mkSymbol() entry (prinl "mkSymbol(new Number(\"" (inc 'Cnt) "\"), \"" Name "\", Pico);" ) ) then skips the code till an empty line. (while (line)) (prin " ") (NIL (skip "#")) ) ) The code will be of interest later. Then it goes to the function area (echo "") and parses "fun.src" a second time (let Cnt (read) (in "fun.src" (skip "#") (loop The purpose is to build a huge 'switch' statement for the PicoLisp primitives. The reason is that an ordered switch (with sequential 'case' values) is much faster than a method dispatch in Java. (let (Name (till " " T) Vars (read)) (line) (prinl "case " (inc 'Cnt) ": // " Name ) The function name is put there as a comment. Short functions are put directly (if (=T Vars) (while (line) (prinl "" @) ) while longer ones are deferred as a call like doXXX(ex); (prinl " " "return do" Cnt "(ex);") (while (line)) ) ) (prin "") (NIL (skip "#")) ) ) ) Finally, it traverses "fun.src" a third time (skip) (echo "") (let Cnt (read) (in "fun.src" (skip "#") (loop (inc 'Cnt) (let (Name (till " " T) Vars (read)) (line) to generate the 'doXXX' functions for the deferred code. Now the short ones are skipped (if (=T Vars) (while (line)) and the longer ones are generated (prinl "final static Any do" Cnt "(Any ex) { // " Name ) Local variables in the functions are declared according to their types (declLocal Vars "int" '(i j k)) ... and the rest of the function body is passed through (while (line) (prinl " " @) ) (prinl " }") Finally, the rest of "sys.src" is written (echo) ) ) and the "javac" compiler called on the product (when (call "javac" "-O" "-g:none" "PicoLisp.java") .. ♪♫ Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Ersatz source code and EmuLisp
On Mon, Oct 31, 2016 at 9:57 PM, Jon Kleiserwrote: > Hi Chri, Hi Jon, > This is how you build ersatz/picolisp.jar, and at the same time get the > complete PicoLisp.java source: > cd into the ersatz/, the do "pil mkJar +". Things I already knew: 1) I knew the purpose and how to use mkJar but my question was more like: in the end, what magic is behind it, like what is the role of «ex»… 2) I knew that it produced then compiled a .java file. Things I learnt reading your answer: Reading the .java file could help me more than the .src files ! Thanks. > I have implemented (partly) a few more functions lately (format, intern, lit, > unless, when), but I haven't released anything new yet. I may find time to > look at 'filter'. Great. Looking forward to it! > Have you had any luck with Clojure(Script)? Yes and no. Yes since I managed to begin to implement my language with it, with a really new vision. Clojure gave me some more ideas. No since it's like I started one more project and time is limited. Also, Clojure uses / as a namespace separator so I cannot create a =/ function (which would translate to <>). All in all, F-expr allows us to do miracles. Clojure can't compete on this field. Macros are tougher. But it has namespaces, that EmuLisp has not (PicoLisp has them). Happy coding. chri -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Re: Ersatz source code and EmuLisp
Hi Chri, This is how you build ersatz/picolisp.jar, and at the same time get the complete PicoLisp.java source: cd into the ersatz/, the do "pil mkJar +". I have implemented (partly) a few more functions lately (format, intern, lit, unless, when), but I haven't released anything new yet. I may find time to look at 'filter'. Have you had any luck with Clojure(Script)? /Jon From: picolisp@software-lab.de <picolisp@software-lab.de> on behalf of Christophe Gragnic <christophegrag...@gmail.com> Sent: 31 October 2016 11:58 To: picolisp@software-lab.de Subject: Ersatz source code and EmuLisp Hi PicoLispers, My question: Is there any documentation about the building of the Ersatz jar ? I guess all the keys are in the mkJar file but I'm lost reading it. Background: I'm mostly using a JavaScript version of PicoLisp: EmuLisp and since Jon Kleiser has not much time to extend it further, I have to try to extend it on my own (this is not a rant! Jon has been very very helpful!). If I understood the process correctly, Jon took inspiration from the source code of Ersatz to structure EmuLisp, but this source is still cryptic to me. My current task is to implement 'filter. This is it's Ersatz implementation: https://github.com/fuxoft/picolisp/blob/1c6c501cd4ad5737ec74fa1de47201060fad39e3/ersatz/fun.src#L641 I tried to mimic 'mapcar https://github.com/fuxoft/picolisp/blob/1c6c501cd4ad5737ec74fa1de47201060fad39e3/ersatz/fun.src#L562 and adapt the mapcar found in EmuLisp: https://github.com/Grahack/EmuLisp/blob/master/emulisp_core.js#L1189 but there are too many things that I don't understand. Can anyone help me ? chri -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe-- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
Ersatz source code and EmuLisp
Hi PicoLispers, My question: Is there any documentation about the building of the Ersatz jar ? I guess all the keys are in the mkJar file but I'm lost reading it. Background: I'm mostly using a JavaScript version of PicoLisp: EmuLisp and since Jon Kleiser has not much time to extend it further, I have to try to extend it on my own (this is not a rant! Jon has been very very helpful!). If I understood the process correctly, Jon took inspiration from the source code of Ersatz to structure EmuLisp, but this source is still cryptic to me. My current task is to implement 'filter. This is it's Ersatz implementation: https://github.com/fuxoft/picolisp/blob/1c6c501cd4ad5737ec74fa1de47201060fad39e3/ersatz/fun.src#L641 I tried to mimic 'mapcar https://github.com/fuxoft/picolisp/blob/1c6c501cd4ad5737ec74fa1de47201060fad39e3/ersatz/fun.src#L562 and adapt the mapcar found in EmuLisp: https://github.com/Grahack/EmuLisp/blob/master/emulisp_core.js#L1189 but there are too many things that I don't understand. Can anyone help me ? chri -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe