4 ms·
> while a list can only be used as the underlying implementation of a map? I certainly wouldn't advise that. We're talking about language syntax here. Lists se
by aasasd 7y ago
> while a list can only be used as the underlying implementation of a map?
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.
- e12e 7y agoBy your definition of lists, misc uses lists to represent maps?
- aasasd 7y agoI guess it can do so. I don't really understand why one would want to ‘base’ the language on maps to promptly go back to lists for putting these integer-keyed maps in. Where's the ‘based on maps’ part then? 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.
- e12e 7y agoA map with integer keys is closer to an array than a list. 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?
- aasasd 7y agoNow your distinctions seem foreign to me. 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.
- e12e 7y agoSince there isn't any traversal when looking up an element n, I guess the best "short hand" would be to call it an array - it's an array of pointers to objects on the heap. https://www.laurentluce.com/posts/python-list-implementation/ https://www.laurentluce.com/posts/python-list-implementation... As for collections within collections, python allows for that in "lists" (arrays) and "dictionaries" (maps).
- kazinator 7y agoThat's not a structure in Python; that's a piece of program syntax which constructs one. 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, ...]?