Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save yurrriq/747b6195b43755da4aec to your computer and use it in GitHub Desktop.

Select an option

Save yurrriq/747b6195b43755da4aec to your computer and use it in GitHub Desktop.
LFE map issues
(let ((m #m(a 1 b (2 3 4) c #(a b)))
(x 'a))
;; Fail
;; (mref m x)
;; (map-get m x)
;; Work
(list
(maps:get x m)
(mref m 'b)
(map-get m 'c)))
@hdurer

hdurer commented Aug 4, 2015

Copy link
Copy Markdown

map-get seems to be just an alias for mref (https://github.com/rvirding/lfe/blob/develop/src/lfe_eval.erl#L133), so they should behave consistently.

mref seems to be a macro that doesn't evaluate the key but only the map argument (https://github.com/rvirding/lfe/blob/develop/src/lfe_eval.erl#L122).
That should maybe read

 Key = map_key(eval_expr(K, Env)),

but maybe not. The documentation is a bit thin about the intended semantics and even the reasoning why this should be a macro and not just a function.

lfe/lfe#136

@yurrriq

yurrriq commented Aug 4, 2015

Copy link
Copy Markdown
Author

Ah, I see. Thanks for raising the issue!

@rvirding

rvirding commented Aug 5, 2015

Copy link
Copy Markdown

I will comment this in the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment