<ecraven>
I've implemented a magic `ref' generic procedure that just references stuff.. I think I like (ref jone :age) more than the *really* magical (:age jone)
<ecraven>
(also, I really wish all Schemes supported keywords :-/)
<ecraven>
as in, self-evaluating symbols, not syntactic keywords
<amirouche>
yeah, using a prefix is 0th can achieve that too
<amirouche>
I am not sure why I do not like generalized set! and generalized ref
<amirouche>
or even (:key mapping)
<nij->
amirouche do you mean beautifulracket does talk about how to create a lang so that (:key map) works as I expected?
<amirouche>
nij-: yes!
<amirouche>
things that comes to mind: 1) I like the idea that most procedure take (most of the time) object with one and only one type that is disjoint; the problem imo with the clojure approach is that I do not see how to implement that, without a set possibly large set of clause in a cond
<amirouche>
re generalized set! I can read (set! (car x) (car y)), and even figure what it does, but I keep wondering how that can possibly work with all containers, including records, without again some cond clause or introspection for records?
<nij->
amirouche Before I read the whole book, could you perhaps hint me on why I was wrong?
<nij->
I was saying that in order to make (:key map) to work, the compiler needs to know the type of :key at runtime.
<nij->
This cannot be done by hacking the macroexpander.
<amirouche>
I am not sure, I am not expert in racket :)
<amirouche>
it depends what the macroexpander does
<nij->
macroexpander comes before the evaluator, and it cannot know what the type of :key is. (I think)
<amirouche>
yes, but it depends on how racket implements custom #lang, imo you need a custom lang, and Scheme like macro expansion is not enough to implement what you need
<leah2>
bah, the expeditor internals are all in unnamed modules so i cant hack them easily :>
<amirouche>
sorry, I will let expert do the explaination
<ecraven>
amirouche: the usual implementation is to register the setter for each getter, which maps `car' to `set-car!'
<amirouche>
ecraven: that is what I call cond clause
<ecraven>
ah, but it is not that ;)
<ecraven>
however, if you want to make this work, you need implementation support
<ecraven>
so define-record-type should register things, some clos-like thing should register things, and so on
<nij->
amirouche no worries! I appreciate your help :D
<ecraven>
nij-: in essence, you need to override what application does
<amirouche>
ecraven: I do not know why I do not like it, I can't put an explanation... seem like too much magic or something, the definition of set! is along the line: `(set! a b)` associate the variable `a` to the object `b` or the the object associated with `b` when `b` is a variable
<nij->
ecraven what is "application"? Do you mean the stage "apply", as in "eval/apply"?
<amirouche>
once you do generalized set! you can write a book about how it works.
<ecraven>
nij-: "function calling"
<nij->
sure! Yes, that's what I meant above.
<ecraven>
I've done it, it isn't hard, but it's more complex than what set! does now, obviously
<nij->
Sometimes I use EVAL to mean eval+apply, as in REPL instead of REAPL.
<nij->
ecraven Right, so racket even has a way for me to change #'apply?
<ecraven>
nij-: yes, and I don't know whether racket supports redefining what application means in custom #langs. I don't know much about racket, sadly
<amirouche>
we are pirates from a nearby dimension
<nij->
At least in beautiful racket, it seems what's described are only about the reader and macroexpander.
<nij->
ecraven you said "yes" to.. that racket allows end users to hack APPLY?
<bremner>
nij-: yeah, I've done that to add dynamic scope (for a demo)
<nij->
Did you hack the racket implementation itself?
<amirouche>
nij-: speed reading beautiful racket, it appears that #lang works as follow: you parse the input, and expand into some "low" level racket lang
<bremner>
nij-: no, just redfined %app, iirc
<nij->
amirouche yeah, so just reader and macro expander
<nij->
bremner! woah.
<amirouche>
nij-: yes, and no. but look into what bremmer wrote above
<nij->
amirouche which part, exactly?
<ecraven>
hm.. search engines don't handle racket very well :-/
<ecraven>
so in essence, define your own %app that does things with keywords, then provide that as #%app
<nij->
that's cool
<amirouche>
welcome to racket land!
<nij->
:D
<nij->
Now this is what I call a truly hackable language.
<ecraven>
I *think* this only works for direct calls, so (map :age jones) might not actually work
<ecraven>
but I have no idea, actually ;)
<amirouche>
...
<amirouche>
With Kernel it is easy to do what you want, but... there is no fast implementation.
<nij->
SO, is %app called every time a lisp form gets evaluated?!
<amirouche>
that is the question is asking ecraven
<amirouche>
fbbg again ;)
<nij->
If it is true, it may slow down racket..
<amirouche>
that is why Kernel is slow :)
<ecraven>
well, it looks like this is tied into macro expansion, so that's just what gets expanded, but for (map :age jones), the function is *map*, not *:age*
<amirouche>
so it is expanded to (you-app map :age jones)
<leah2>
yet map somewhere calls apply
<amirouche>
yes, map may call an optimized, lower form kind of apply, or even be completly implemented in C, before racket cs
<ecraven>
yes, but not #%app, would be my (completely unfounded) guess
<amirouche>
and oblivious of the custom #%app
<amirouche>
read the code nij- it is there, it is open, it is free, it is an cli dance away: git clone https://github.com/racket/