MISC: A homoiconic language based on maps
will.thimbleby.net
will.thimbleby.net
Obviously false, as demonstrated by Lisp, with which the author must be familiar.
The problem with maps as a basis for a programming language is that you need expressions to have one entry point which says what expression this is. In a sequence, an obvious choice is the first element, or sometimes the last. This is why YAML-programming expressions in Ansible in fact work exactly like regular function calls, with their “- function: argument argument” syntax (which Ansible authors seem to not notice). ‘Misc’, of course, also has to choose ‘0’ to represent the expression entry point.
I think this syntax is translatable one-to-one to old Lisp syntax, probably with keyword arguments.
Specifically for lisp, a list is a sequence of cons cells, and you would have to do a linear search to look up a value by key - thus, it can function as a map from an Api point of view, but not in terms of performance?
That's why the common lisp "map" is a hash table, not a list?
I certainly wouldn't advise that. We're talking about language syntax here. Lists serve alright for maps in the syntax (personally I like Clojure's curly-brace literals), but I sure hope that the implementation uses hash maps or something like that.
I also have no idea why lists have to be linked-lists and made of cons cells. Lisps working on top of pre-existing environments, like Clojure, don't seem to bother with that requirement, so it looks like it's just an idea from the stone age of computing.
It would be really map-based, in my book, if it used named arguments for every function—though that would be incredibly cumbersome (ahem ObjC cough). As it is, it's just regular Lisp but with map keys having colons on the right instead of the left.
I'm not sure I follow your arguments - you seem to be talking of "lists" as some sort of string syntax, possibly as some form of abstract syntax - but either way separate from the abstract data structure?
That's not how I read the comment from the misc page - they seem to be talking about the ADT - much like clojure chose to not use lists made from cons pairs?
Let's look at this structure in Python:
["qwe", 1.1, True, None, [], var1]
Is this an array, a linked list or what? Can an integer-indexed map be mapped onto this structure?
To me it looks perfectly cromulent for making a Lisp.
https://www.laurentluce.com/posts/python-list-implementation...
As for collections within collections, python allows for that in "lists" (arrays) and "dictionaries" (maps).
Python is confused between the two, but here we have a telltale detail that tells us which this is: the presence of var1.
Can you write a Python function which returns a list that contains var1 as an element, so that it prints exactly as [... ,var1, ...]?
https://wiki.c2.com/?MaspBrainstorming
https://www.reddit.com/r/compsci/comments/brrzad/universal_p...
https://www.reddit.com/r/ProgrammingLanguages/comments/e8f8c...
I don't know if there is any relationship between authors. The idea of applying the lessons and benefits of XML to imperative programming to form a kind of meta language or meta-friendly language is present.
For common lisp, for example, it's probably fair to say that an over use of lists is "wrong" in the general case (ie, if your problem is data driven, which would probably be the case in most applications/utilities).
Now, if all you're doing is improving the language/honing a DSL - the you'll probably be using lists a lot, as that is what constitutes the abstract syntax tree you're manipulating.
See this for a brief discussion on collections in common lisp:
EDIT - how does one actually run a Java applet nowadays? Which browsers still support that integration?
cd $(mktemp -d)
wget http://will.thimbleby.net/misc/misc.jar
wget http://will.thimbleby.net/misc/bootstrap.misc
java -jar misc.jar
And then it drops you into a repl. (Add `rlwrap` in front of `java -jar` if cursor movement doesn't work correctly)Note to self: if I wanted to distribute Java malware to the HN crowd this is exactly how I would do it: write a minimalist, nerdy topic that requires an applet to run, knowing that my audience will happily find a work-around, like the above.
But your reminder is good for the newcomers around I guess.
Source: https://en.wikipedia.org/wiki/Befunge
v>>>>>v
12345
^?^
> ? ?^
v?v
6789
>>>> v
^ .<