15 ms·
janet:1:> (cons 1 2) compile error: unknown symbol cons on line 1, column 1 while compiling repl janet:2:> (list 1 2) compile error: unknown symbol
by phoe-krk 6y ago
janet:1:> (cons 1 2)
compile error: unknown symbol cons on line 1, column 1 while compiling repl
janet:2:> (list 1 2)
compile error: unknown symbol list on line 2, column 1 while compiling repl
janet:3:> (vector 1 2)
compile error: unknown symbol vector on line 3, column 1 while compiling repl
I certainly need to learn the basic idioms of this dialect; it looks nothing like Common Lisp under the hood.
- pjc50 6y agoIs it really Lisp without cons?
- deleted 6y ago[deleted]
- phoe-krk 6y agoYes, it seems so. Try the REPL available at the website.
- oblio 6y agoI wonder if his question was not rhetorical, as in: It is really Lisp if it doesn't have cons?
- phoe-krk 6y agoThat question has been a source of multiple flamewars in the past that have only made the world worse as a result. I prefer not to go down that hole again.
- lispm 6y agoIs it really Lisp without 'lists'? https://janet-lang.org/api/index.html https://janet-lang.org/api/index.html that does not mention list in meaningful ways. It seems to prefer to work with other data structures (like arrays) - which is okay, but then I won't call it a List Processor dialect.
- jonathanstrange 6y agoI don't understand why somebody downvoted you, I've seen a number of languages that look like Lisp, but are based on vectors or arrays, and that changes the language drastically. So I'm wondering, too. I was trying to find out whether Janet programs are lists or something else like arrays, but didn't find it in the docs.
- bakpakin 6y agoThis does change the language drastically - source code is represented as tuples usually, although all of the core data structures have literal forms. This means writing macros is still easy, although certain idioms like consing are usually replaced by splicing, which is like unquote-splicing in Common Lisp but more general.
- hexmiles 6y agoas someone who dosen't know the theory what is the difference between list and array? consing and splicing? is there a pratical difference in the way you write programs or is more of theory/implemetation detail?
- bakpakin 6y agoA list refers to a singly-linked list, while tuples are implemented as immutable arrays. The former is flexible in that multiple lists can hare structure, and prepending to a list is an O(1) operation that does not change the original list (consing). This property allows all sorts of interesting data structures which at their core are simply lists of atoms and other lists. Janet on the other hand just uses tuples, which are easier to pack densely into memory so usually have better cache performance on reads (clever lisp implementations can sometimes can make lists fit densely in memory, but usually they take about twice as much memory as a tuple). splicing is the like the spread operator in JavaScript or the splat operator in Ruby. This turns out to be very useful in a language without cons for manipulating tuples in macros, even though it is not as efficient as a cons.
- alexkowalenko 6y agoIs it a lisp without car cdr and cadaaaadmycateatsmiceadaddddr? Just in case - ))))))))))))))))))))))))))))))))))))))
- pull_my_finger 6y agoI can understand it's a traditional name, but maybe we can appreciate that it's a new/stand-alone language and that modern/expressive function names are an improvement and a breath of fresh air.
- flavio81 6y agoMore precisely, Lisp ... without cons, without arbitrary precision integers, fixed precision integers, rationals and complex numbers, without image-based development, without the conditions-restart system, without CLOS, etc. It's interesting to note, since Janet is a bytecode interpreter, that we've have had a full Common Lisp implementation for years (CLISP) that provides all the features above (plus many many others) with a download size (1.8MB) just slightly bigge than to Janet's.
- dmos62 6y agoI found this interesting so looked it up: Janet 1.9.1-4ae3722 Copyright (C) 2017-2019 Calvin Rose janet:1:> (array 1 2 3) @[1 2 3] janet:2:> (tuple 1 2 3) (1 2 3) janet:3:> (rest (tuple 1 2 3)) compile error: unknown symbol rest on line 3, column 1 while compiling repl janet:5:> (tail (tuple 1 2 3)) compile error: unknown symbol tail on line 5, column 1 while compiling repl janet:6:> (car (tuple 1 2 3)) compile error: unknown symbol car on line 6, column 1 while compiling repl janet:7:> (cdr (tuple 1 2 3)) compile error: unknown symbol cdr on line 7, column 1 while compiling repl janet:8:> (def t (tuple 1 2 3)) (1 2 3) janet:9:> (def a (array 1 2 3)) @[1 2 3] janet:11:> (drop 1 t) (2 3) janet:12:> (drop 1 a) (2 3) janet:13:> (first t) 1 janet:14:> (first a) 1