User Controls
So I guess I'm writing a lisp
-
2015-07-15 at 6:29 AM UTCI wanted to mess around with the jasmine unit testing framework so I was like "I'll write a lisp lexer" and then I wanted to make it testable and for that (very bad) reason I make the lexer purely immutable. And once I was there I was like "well I'll add a parser to see how far I can carry this immutable thing" and it turns out I'd have to implement an actual finger tree to make that work quasi-efficiently and I couldn't be fucked with that so my parser isn't immutable but at the point I had parse trees I was like "well they always said eval/apply was simple, I'll just do that" and hot damn, it ended up being like 40 lines of code from ASTs to execution (excluding language primitives which I'm still implementing) but it's actually been pretty fun even if it's pretty far removed from getting used to jasmine at this point. Anyway, actually implementing eval/apply was kind of a mind expanding experience, I'm still a little amazed it works. Here's the repo at the moment:
https://github.com/RyanJenkins/rose-lisp
`node src/core` will start a REPL although I've only implemented the +, if, and let binds at this point. Anyway, any other lisp fans out there? Anyone ever implement an interpreter/compiler before, any tips? -
2015-07-20 at 5:43 AM UTCOh shit, nice stuff man. I'll give it a looking-over when I get back from work. I've had good times with a lisp (clojure) but sadly I haven't found a single application for it outside of my own hobby projects.
-
2015-07-20 at 10:03 AM UTCI'm not quite sure what you're talking about but i'm happy you had an enlightening experience.
-
2015-07-22 at 2:13 AM UTCJust pushed some new stuff. Working on this in spare time at work and can't access my personal github there so the commits are kinda monolithic, but w/e.
I implemented `let` before lambdas so at first I was like "well shit, that's wasted code" because you can implement as a macro like this (in clojure (and assuming I didn't mess quoting up there, I'm still not really a macro wizard)):
(defmacro let [binds &body] `((fn ~(take-nth 2 binds) ~@body) ~@(take-nth 2 (rest binds))))
(expandmacro '(let [x 40 y 2] (+ x y)))
; outputs ((fn [x y] (+ x y)) 40 2)
And ignoring destructuring that's pretty much how let is implemented in scheme and CL but then I realized that there's a scoping issue because under that scheme doing something like:
(let [x 40 y (+ x 2)] y)
will fail because x won't be bound in the env that `(+ x 2)` is executed in (strict/eager evaluation means the args are fully evaluated before a function is applied to them) so I don't feel so bad about implementing let as a special form (in scheme and CL you have macros like `lets` (I think it's called) that expands to nested lambdas (that is a series of 1-argument immediately evaluated lambdas) to deal with this situation and it's definitely "purer" in one sense, one fewer special forms, but kinda ugly IMO).I'm not quite sure what you're talking about but i'm happy you had an enlightening experience.
Heh, writing a programming language. This article has a little snippet of pseudocode that implements eval/apply which is the core of the lisp family of languages. It's (IMO) pretty profound despite being almost trivially simple. -
2015-07-22 at 2:26 AM UTCBy the way Lan i made a github to talk to the dev of that backdoor about some issues and such. I'm following you too, follow me back nigger or whatever it's called on github, i am watching your repo at least lol https://github.com/SophieSecBot
Heh, writing a programming language. This article has a little snippet of pseudocode that implements eval/apply which is the core of the lisp family of languages. It's (IMO) pretty profound despite being almost trivially simple.
That's pretty cool bro i'll give the article a read.
-
2015-07-22 at 2:56 AM UTC
By the way Lan i made a github to talk to the dev of that backdoor about some issues and such. I'm following you too, follow me back nigger or whatever it's called on github, i am watching your repo at least lol https://github.com/SophieSecBot
Haha, totes. My activity feed is always just tim pope pumping out nigger-tons of commits because even my programmer friends are terrible about keeping their githubs up to date, so I'm always glad to have someone new to follow.That's pretty cool bro i'll give the article a read.
Yeah, C2 can be kinda strange because the pages are kinda roughly sewn together by a bunch of people but the stuff contained there is useful enough that it's become a kind of watering hole in certain programmer communities. -
2015-07-22 at 3:06 AM UTC
Haha, totes. My activity feed is always just tim pope pumping out nigger-tons of commits because even my programmer friends are terrible about keeping their githubs up to date, so I'm always glad to have someone new to follow.
Cool man.Yeah, C2 can be kinda strange because the pages are kinda roughly sewn together by a bunch of people but the stuff contained there is useful enough that it's become a kind of watering hole in certain programmer communities.
I can't say i fully understand all the concepts that are programming related but it looks interesting nonetheless. -
2015-07-22 at 3:21 PM UTCI understand ALL OF THIS and you're doing it ALL WRONG. First of all, it is LITHP, not LISP:. Secondly it's not FINGER TREE, it's TOE BUSH. Thirdly, it's not LEXER and PARSER, but rather LUTHER and SNIPPER. Fourthly, it's not JASMINE, it's LAVENDER. Lastly, it's not NESTED LAMBDAS, but instead the correct term is FORTRESSED ABDUHLAS.
-
2015-07-22 at 4:05 PM UTC
<?php
$mqvar="LITHP";
if($mqvar=LITHP=""){echo "LISP Comes next!";}
elseif($mqvar=="TOE BUSH"){echo "Doing great so far";}
else{echo "Too lazy to add, luther, snipper and fortressed abdullahs.";}
?>
Better like this mQ? Anyway i don't even PHP, don't i need to indent with if/else statements? I'm used to python. -
2021-04-07 at 3:02 AM UTC
Originally posted by mmQ I understand ALL OF THIS and you're doing it ALL WRONG. First of all, it is LITHP, not LISP:. Secondly it's not FINGER TREE, it's TOE BUSH. Thirdly, it's not LEXER and PARSER, but rather LUTHER and SNIPPER. Fourthly, it's not JASMINE, it's LAVENDER. Lastly, it's not NESTED LAMBDAS, but instead the correct term is FORTRESSED ABDUHLAS.
Lol