5 ms·
> Each time you define a method or a class (C#, Java, C++), you're extending and defining your "language". One mostly only adds new words to these languages: n
by lispm 8y ago
> Each time you define a method or a class (C#, Java, C++), you're extending and defining your "language".
One mostly only adds new words to these languages: nouns and verbs. With Lisp you can add new syntax as a user as part of the program. This allows us to do code transformations at compile time as part of a program. This allows us relatively straight forward to generate more complex code from simpler descriptive code.
- Koshkin 8y ago> With Lisp you can add new syntax "With Lisp you can have any syntax, as long as it looks like Lisp."
- lispm 8y agoUnless it doesn't: CL-USER 14 > (loop for i from 0 below 10 sum i into isum when (evenp i) sum i into evensum of-type integer else when (oddp i) sum i into oddsum finally (return (* isum evensum oddsum))) 22500
- int_19h 8y agoArguably that still looks like Lisp (i.e. it's a valid S-expression). But then you also have reader macros...
- lispm 8y agoWell, s-expressions are not Lisp. Not every s-expression is a valid Lisp program. (1 * 2 ^ 3 + 1) is a valid s-expression, but not a valid Lisp program. With an INFIX macro it could be: (infix 1 * 2 ^ 3 + 1) could be a valid Lisp program, with a corresponding infix macro. But the Lisp syntax still is on top of the s-expression syntax...
- zvrba 8y agoI could do that in C# as well if I felt I needed it. Define classes representing the "syntax/AST", utility functions to build the AST and an interpreter that compiles the AST to an expression tree which in turn is an executable lambda. It's what EFCore does, translates C# method calls into SQL statements via lambdas bound to expression trees. So, no, LISP is not special in that regard.
- lispm 8y ago> LISP is not special in that regard It's just MUCH MUCH easier, standardized and widely used.
- zvrba 8y ago> easier For routine code generation, there are even simpler T4 templates. That one gets as easy as one could want. > standardized So are expression trees: https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions?view=netcore-2.2 https://docs.microsoft.com/en-us/dotnet/api/system.linq.expr... > and widely used By what statistics?
- lispm 8y ago> So are expression trees But they are not easier. Pick one or two out of three. > By what statistics? Number of defined or used macros per lines of Lisp code.