So for a long time I found LISP elegant but I found the syntax infuriating.
-
So for a long time I found LISP elegant but I found the syntax infuriating. Then I made my own LISP variant with semi-significant whitespace and helper syntax— each line (up to whitespace or comma) is wrapped in an implicit (), a : wraps a () to the end of the line, a {} wraps its interior in (lambda), a [] wraps its contents in (list ), "x.y" becomes "get x y". Suddenly, I found it usable!
I wonder if I could just make an editor that applies these rules implicitly, and then I could use GUIX.
( Look how fundamentally un-LISP-y my LISP is. I'm proud of it. https://codeberg.org/mcc/nameless-experimental-lisp/src/branch/unstable/sample/fizzbuzz.l0 )
EDIT: Wait, I think this sample code might be a bit out of date… this is from before the language had a "while" builtin, so it defines a "while" operation in terms of "if".
-
( Look how fundamentally un-LISP-y my LISP is. I'm proud of it. https://codeberg.org/mcc/nameless-experimental-lisp/src/branch/unstable/sample/fizzbuzz.l0 )
EDIT: Wait, I think this sample code might be a bit out of date… this is from before the language had a "while" builtin, so it defines a "while" operation in terms of "if".
@mcc I like that it kinda looks like Tcl at a cursory glance
-
( Look how fundamentally un-LISP-y my LISP is. I'm proud of it. https://codeberg.org/mcc/nameless-experimental-lisp/src/branch/unstable/sample/fizzbuzz.l0 )
EDIT: Wait, I think this sample code might be a bit out of date… this is from before the language had a "while" builtin, so it defines a "while" operation in terms of "if".
@mcc nice, i'm writing my own javascript, but it is taking forever
-
@mcc I like that it kinda looks like Tcl at a cursory glance
@lobo oh gosh i'm so glad you noticed this because this was LITERALLY my attempt to make a LISP that felt like TCL. I learned TCL and was like "this is compelling but too unhygenic, what if I made something halfway between TCL and LISP"
-
( Look how fundamentally un-LISP-y my LISP is. I'm proud of it. https://codeberg.org/mcc/nameless-experimental-lisp/src/branch/unstable/sample/fizzbuzz.l0 )
EDIT: Wait, I think this sample code might be a bit out of date… this is from before the language had a "while" builtin, so it defines a "while" operation in terms of "if".
@mcc It looks like everything between print and sp gets wrapped in one set of parens? How does the reader decide when to insert the ')'?
Does a single word on a line get wrapped?
Looks like you wrap your if/while bodies in an extra set of parens than conventional Lisp, is that right?
-
@mcc It looks like everything between print and sp gets wrapped in one set of parens? How does the reader decide when to insert the ')'?
Does a single word on a line get wrapped?
Looks like you wrap your if/while bodies in an extra set of parens than conventional Lisp, is that right?
@mcc Oh, no if/while wrap in lambda not just parens.
-
@mcc Oh, no if/while wrap in lambda not just parens.
@mcc cond is a particularly challenging form I never managed to come up with a clean formatting for.
(You can see examples including fizzbuzz of my whitespace sensitive Lisp at https://rosettacode.org/wiki/Category:Wart)
-
@mcc It looks like everything between print and sp gets wrapped in one set of parens? How does the reader decide when to insert the ')'?
Does a single word on a line get wrapped?
Looks like you wrap your if/while bodies in an extra set of parens than conventional Lisp, is that right?
@akkartik ( is inserted at start of line, ) is inserted at end of line. An unclosed ({[ within a line extends the line. A blank line is ignored. so yeah, one ( before the "print", one ) after the "sp".
Single word on a line is the grammar's one awkward case. Single word on a line is *exempt* from the () wrapping. This is because otherwise the [] list blocks would be very hard to form sensibly. A bare word on a line is treated as just that word's value, and it's not executed like a function.
-
@akkartik ( is inserted at start of line, ) is inserted at end of line. An unclosed ({[ within a line extends the line. A blank line is ignored. so yeah, one ( before the "print", one ) after the "sp".
Single word on a line is the grammar's one awkward case. Single word on a line is *exempt* from the () wrapping. This is because otherwise the [] list blocks would be very hard to form sensibly. A bare word on a line is treated as just that word's value, and it's not executed like a function.
@akkartik Since this means that most lone words alone on a line are noops, to be "helpful", the interpreter treats it as an error when it encounters a lone-word statement (unless that statement is the final line of a {} block, in which case it is returned as the evaluation result of the block)
-
@mcc cond is a particularly challenging form I never managed to come up with a clean formatting for.
(You can see examples including fizzbuzz of my whitespace sensitive Lisp at https://rosettacode.org/wiki/Category:Wart)
@akkartik This was my approach to cond, I called it the "match" statement
I think it's quite readable, but when writing it it's a bit frictiony to have to remember when to use [], when to use {}, and when to use () to get the results you wanted. (Note "match" is a *function* defined further up in the file; this LISP has no special forms, even the {}:. syntax isn't special forms, it's just inserting (, ) and ' in various ways.)
-
@akkartik This was my approach to cond, I called it the "match" statement
I think it's quite readable, but when writing it it's a bit frictiony to have to remember when to use [], when to use {}, and when to use () to get the results you wanted. (Note "match" is a *function* defined further up in the file; this LISP has no special forms, even the {}:. syntax isn't special forms, it's just inserting (, ) and ' in various ways.)
@akkartik Are there any examples of cond in the examples list above?
-
@akkartik Are there any examples of cond in the examples list above?
@akkartik By the way, something that may not be obvious in my sample code. I said {} is "lambda", but I was simplifying for space. {} is an argument-less lambda. In fact, {a b, c d} is shorthand for '((a b)(c d)). You upgrade a quoted list (a {}) to a function by passing it to the fn or set-fn builtin functions.
-
-
@akkartik Are there any examples of cond in the examples list above?
@mcc I basically got rid of cond because the `((` pattern seemed to require new delimiters. So instead `if` is multi branch as you can see in fizzbuzz.
My approach was to keep it memorable by minimizing delimiters. There are only parens, just like in regular Lisp. You can just avoid inserting parens sometimes, that's it. (And then infix arithmetic and $ for implicit gensyms 😄 I should create a version with just the paren insertion rules.)
I used the same approach as you for single word lines. No parens around them, but no error either.
-
@mcc I basically got rid of cond because the `((` pattern seemed to require new delimiters. So instead `if` is multi branch as you can see in fizzbuzz.
My approach was to keep it memorable by minimizing delimiters. There are only parens, just like in regular Lisp. You can just avoid inserting parens sometimes, that's it. (And then infix arithmetic and $ for implicit gensyms 😄 I should create a version with just the paren insertion rules.)
I used the same approach as you for single word lines. No parens around them, but no error either.
@akkartik Oh, multibranch if makes sense.
I'm actually doing a vaguely bizarre thing where the if statement can have an optional "else" because "else" is a global symbol which is defined as "false". If the symbol is non-false (eg, a block) it's treated as a case. i'm considering defining "elif" as "true" and special-casing that to determine whether the next item is a case or a condition.
-
@akkartik Oh, multibranch if makes sense.
I'm actually doing a vaguely bizarre thing where the if statement can have an optional "else" because "else" is a global symbol which is defined as "false". If the symbol is non-false (eg, a block) it's treated as a case. i'm considering defining "elif" as "true" and special-casing that to determine whether the next item is a case or a condition.
-
@SpindleyQ @mcc I've been annoyed by the lack of keywords in Lisp conditionals for.. (https://github.com/akkartik/wart/commit/c2e6d0c6d3) almost 14 years. Indentation should either mean "code that also runs" or "code that sometimes runs". When it can be either in a single stanza the result is shit.
-
So for a long time I found LISP elegant but I found the syntax infuriating. Then I made my own LISP variant with semi-significant whitespace and helper syntax— each line (up to whitespace or comma) is wrapped in an implicit (), a : wraps a () to the end of the line, a {} wraps its interior in (lambda), a [] wraps its contents in (list ), "x.y" becomes "get x y". Suddenly, I found it usable!
I wonder if I could just make an editor that applies these rules implicitly, and then I could use GUIX.
@mcc wait, are you aware of Wisp <https://www.draketo.de/software/wisp>, the indentation+shortcuts Scheme syntax?
It’s one of the supported syntaxes in Guile, so you can theoretically use it to write Guix packages.
-
@mcc wait, are you aware of Wisp <https://www.draketo.de/software/wisp>, the indentation+shortcuts Scheme syntax?
It’s one of the supported syntaxes in Guile, so you can theoretically use it to write Guix packages.
@aartaka I think it's very interesting!
I didn't know it was an option for Guix. That's good to know.
-
@aartaka I think it's very interesting!
I didn't know it was an option for Guix. That's good to know.
@mcc it’s an option for *Guile*. I’m not sure if it extrapolates to practical Guix programming, despite Guix being implemented in Guile. I don’t want to lead you astray here, because I’m uncertain myself 😅