Arc Forumnew | comments | leaders | submitlogin
1 point by shader 4864 days ago | link | parent

For the most part, I don't mind this behavior. There's only one case where I with this was not the case, in which I was writing a compiler in arc which attempted to represent the ast as symbols in lists. Silly me, thinking that was the right way to represent an ast in arc.

The problem is that if someone were to use a variable in that language named nil, it would be represented in my ast as 'nil, which would then be treated in all of the rest of the code (including any parts which printed it out) as if it weren't there. I guess I should have used strings in all of those cases, but I was taking advantage of the fact that I could actually bind values to the symbols to store some metadata. It turned out to be a really handy way to work with the language, unless someone used 'nil as a variable. Doing anything else would have worked better, but been more verbose and hackish.

This is the only reason I wish that nil -> '() instead of nil = '(). Because |()| != '(), while |nil| = 'nil.



1 point by Pauan 4863 days ago | link

I think this should be configurable in ar, with the default being to follow Arc/3.1, but still allow the programmer to make nil different from 'nil.

Hey awwx, how hard would it be to make this change in ar right now? From what I can see, "nil" is just a global variable bound to the symbol 'nil. So, what if I did this...?

  (ail-code (racket-set! nil (uniq)))
It seems to work okay in the couple tests I did, but I wonder if it would break anything...

-----

1 point by Pauan 4863 days ago | link

Hm... I just realized ar allows for rebinding nil and t! So you can just do this:

  (= nil (uniq))
Neat.

-----

1 point by Pauan 4863 days ago | link

By the way, if you ever decide to rebind nil, and it breaks stuff, you can fix things by doing this:

  (assign nil 'nil)
You need to use `assign` rather than `=` because `=` breaks if nil isn't 'nil.

-----

1 point by rocketnia 4863 days ago | link

"I guess I should have used strings in all of those cases, but I was taking advantage of the fact that I could actually bind values to the symbols to store some metadata."

If you don't mind, how does/did it seem easier to bind values to symbols than to bind them to strings?

-----

2 points by Pauan 4863 days ago | link

I'm not shader, but I'm guessing that it's because... you can't.... bind values to strings...?

I mean, yeah, you could have a table where the keys are strings, and treat that as the metadata, but uuugh it's clunky and I've found myself disliking the whole "global table to hold data" thing more and more, recently.

Then again, I don't know how their compiler works, so I might be completely off-base here...

-----