News for hackers. Stuff that matters.
Re:ChrysaLisp by lvh on Monday January 13, 2020 @10:07AM (#22035025)
What makes it "not actually Lisp but some new language with a superficially Lisp-like syntax"? (Never mind that it's ostensibly a lot more than just a language but an entire OS with a Lisp-geared runtime -- I'm assuming you're just referring to the language).

https://github.com/vygr/ChrysaLisp/blob/1808d2db54cdda378aae... sure looks like plausibly a Lisp dialect to me.

Is your objection to the execution VM (all the files ending in .vp)?

Re:ChrysaLisp by DannyB2 on Monday January 13, 2020 @10:36AM (#22035317)
1. no garbage collector

2. No tail recursion

3. There is no cons, cdr or car stuff. Lists are just vector objects and you use push, cat, slice etc to manipulate elements.

Only this much is radical enough to say that it isn't a Lisp but disguised in Lisp syntax. Lisp is as much about semantics as the syntax. The power of Lisp to do amazing things comes from the language capabilities. If you cannot reasonably translate powerful programs from Lisp textbooks, then is it a Lisp?

Some languages (example: JavaScript, Python) make it easy to create an inefficient Lisp interpreter that could execute common textbook programs. Minimax, A-star search, unification matching, etc.

Re:ChrysaLisp by lvh on Monday January 13, 2020 @10:40AM (#22035358)
Welp, you're right, all of those things are true for the lisp files too (not just vp). I just read some sample source and missed https://github.com/vygr/ChrysaLisp/blob/5483e0926b926c2cde63... . I agree those are pretty serious deviations that make "only superficially lisp-like" a reasonable statement. Thanks!

(IIUC the "garbage collector" is refcounting; I'm not sure what "All objects used by the Lisp are reference counted objects from the class library." means in practice, and specifically I'm not sure if that means "you basically have a GC in lisp as long as you don't make cycles".)

Re:ChrysaLisp by vygr on Monday January 13, 2020 @12:33PM (#22036556)
It means what it says ;)

All objects used by the Lisp are instances of classes from the class library, ie that stuff in class/ folder.

These instances are ref counted objects, as they are derefed and they drop to 0 refs they get deinited and freed.

The Lisp is constructed from these, for example Lists in the Lisp are an instance of the class/vector, numbers are an instance of class/num, the environment is a chain of class/hmap etc.

So yes, you do have GC if you don't make cycles, and you do have to care about not doing that just as you would in C++.

Re:ChrysaLisp by vygr on Monday January 13, 2020 @12:21PM (#22036439)
There is currently no GC, by choice, but I recently did some work to assist the Stats app that I added recently that could lead to me implementing a GC at some point in the future.
Re:ChrysaLisp by pjmlp on Monday January 13, 2020 @01:42PM (#22037239)
Lisp does not require tail recursion, only Scheme does.
Re:ChrysaLisp by mnemonicsloth on Monday January 13, 2020 @09:09PM (#22041155)
Most Common Lisps (certainly the compiled ones) do tail call optimization.

Clojure doesn't because it's a Lisp in Java, and Java doesn't. Back when Clojure was just starting to get some attention I watched a video [1] of Rich doing a demo for a user group. Tail call optimization was one of their first questions. He gave them an answer that sounded like he had given it multiple times before.

[1] can't find it, sorry.

Re:ChrysaLisp by lvh on Tuesday January 14, 2020 @10:59PM (#22051658)
> Clojure doesn't because it's a Lisp in Java, and Java doesn't.

I keep hearing this and I have no idea where it comes from. x86_64 doesn't either, Clojure has recur, and prefers consistent var semantics to silently specialcasing some tail calls. There's no particularly good reason the compiler couldn't just do it.

Re:ChrysaLisp by kazinator on Thursday January 16, 2020 @12:06PM (#22066457)
The JVM defines a particular model for program organization, which is largely inescapable from the point of view of someone targeting a language front-end to it.

x86_64 instruction set gives the programmer complete control over the organization of memory: the stack, use of registers, calling conventions and so on.

It has few safety features.

x86_64 doesn't specifically support tail calls, but it makes tail calls possible by way of jump instructions being able to go anywhere in the address space. An instruction in the middle of one function can branch to an instruction in the middle of another function, and without doing anything with the registers or stack.

The JVM byte code doesn't allow such a thing.

The JVM supports iteration. Therefore local tail calling is possible, because it's a syntactic sugar for local control transfers. That's presumably why Clojure can have recur.

Re:ChrysaLisp by lvh on Sunday January 26, 2020 @07:23PM (#22155886)
That sounds like a long-winded way of saying "x86_64 and the JVM are different but neither prevents TCO", which is precisely my point! Unless your point is "it's not TCO unless it's literally an instruction called 'jump' and iteration transforms don't count"?
Re:ChrysaLisp by lispm on Wednesday January 15, 2020 @12:07PM (#22055955)
For every function call it should not grow the stack and jump into the function. The JVM does not support that. One would need to compile the code in complex ways - function calls would no longer map directly to JVM instructions.
Re:ChrysaLisp by lvh on Wednesday January 15, 2020 @12:54PM (#22056464)
You're explaining TCO. I understand how TCO works.

I'm going to rephrase my own argument because it doesn't appear you interacted with it: what part of your argument doesn't work for x86_64? "One would need to compile the code in complex ways: function calls would no longer map directly to CALL/RET instructions." Sure! That's arguably what makes it an optimization. Who cares? CPUs can loop, and so can the JVM.

I would maybe see your point if Clojure didn't already know how to do tail calls (and so would need to implement the allegedly complicated compilation step), but as I have pointed out several times: it already has `recur`, which lets you call a function without the JVM thinking there is a function call going on.

Re:ChrysaLisp by lispm on Wednesday January 15, 2020 @05:16PM (#22059377)
Tail recursion optimization would be when the compiler on its own would recognize tail recursion calls and generate special code for that.

That one needs to manually annotate it in Clojure just means that the compiler is manually instructed to generate a loop-like construct instead of a function call.

The advantage in Clojure is that these loops are explicitly marked, which IMHO improves readablity.

Many Lisps don't bother to implement tail recursion optimization, because they support the more general tail call optimization - by adjusting/reusing the current stack frame and using a JMP instruction.

Re:ChrysaLisp by pjmlp on Tuesday January 14, 2020 @01:16AM (#22042316)
Yes it is a common optimization, however it is not a requirement for Common Lisp standard compliance, like it happens with Scheme.
Re:ChrysaLisp by rini17 on Monday January 13, 2020 @11:44AM (#22036023)
IMO closures and macros are absolutely essential, not just conses.
Re:ChrysaLisp by lvh on Monday January 13, 2020 @12:13PM (#22036357)
It ostensibly has both macros and closures, though. The lisp source i linked creates an anonymous function and uses it with map (which I assume means it has real closures though I guess you could fake that too), and here are some macros: https://github.com/vygr/ChrysaLisp/blob/bb4ad4116d6e794eb66e...