Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guide: formaly introduce map and vector literals #563

Merged
merged 1 commit into from
May 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions process/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,26 @@ and each step will give progressively more bang for the buck.
a similar prefixed translation anyways).
* vector: a vector can be implemented with same underlying
type as a list as long as there is some mechanism to keep track of
the difference. You can use the same reader function for both
the difference.
Vector literals are similar to lists, but use bracket as
delimiters instead of parenthesis.
For example, `[]` constructs an empty vector and `[1 "a"]` a
vector with two elements.
You can use the same reader function for both
lists and vectors by adding parameters for the starting and ending
tokens.
* hash-map: a hash-map is an associative data structure that maps
strings to other mal values. If you implement keywords as prefixed
strings, then you only need a native associative data structure
which supports string keys. Clojure allows any value to be a hash
map key, but the base functionality in mal is to support strings
and keyword keys. Because of the representation of hash-maps as
and keyword keys.
Hash-map literals are constructed with braces delimiters.
For example,
`{}` constructs an empty map,
`{"a" 1 :b "whatever"}` associates the `a` key to an integer value
and the `:b` key to a string value.
Because of the representation of hash-maps as
an alternating sequence of keys and values, you can probably use
the same reader function for hash-maps as lists and vectors with
parameters to indicate the starting and ending tokens. The odd
Expand Down