Il giorno 27/mag/2015, alle ore 13.08, Alexander D. Knauth ha scritto:

> 
> On May 27, 2015, at 6:13 AM, Michael Tiedtke <michael.tied...@o2online.de> 
> wrote:
> 
>> I'm a little bit astonished that Racket doesn't offer a defined? primitve 
>> when it's not
>> possible to implement it with macros because of the strange compile-time 
>> behavior.
> 
> Here’s a fairly useless macro that can tell if a given identifier is defined 
> or not:
> #lang racket
> (require (for-syntax racket/base syntax/parse))
> (define-syntax defined?
>   (syntax-parser
>     [(defined? x:id)
>      (if (identifier-binding #'x)
>          #'#t
>          #'#f)]))
> (defined? x)
> (define y 3)
> (defined? y)
> (let ([x 4])
>   (defined? x))
> 
> 
>> Where compile time sound to me like put all the interned things together, 
>> call it
>> byte code and dump it into a file.
> 
> Well, there’s expansion time, which is the part of “compile time” in which 
> macros expand, and in racket that’s often what people are talking about when 
> they say compile time.

The reader stage does the compilation. It pulls in different parts into one 
collection or compilation in memory with the mentioned expansion time. It 
interns symbols, constants and definitions probably after doing some text 
processing. Then there might be an on-the-fly optimization stage and at some 
point one might want to create an executable file. All of this - not specific 
to Racket - might be called compilation.

To load the executable it needs to have all the "system level dependencies" on 
board because of some previous linking stage or the linker prepared it for 
dynamic linking. That's because todays systems are based on UNIX / C calling 
conventions and application binary interfaces when it comes to linking. Again 
with the "evolution" to message passing there was little change but all in all 
it's not very s-exp Read-Eval-Dump/Link friendly ... even todays system runtime 
evironment is a lot of UNIX process management with the addition of kernel 
servers, DRM, sandboxing, code signing (where I do not know or trust the 
certificate authorities) and intellectual property management. Up to that point 
that I can't load and edit my own recording of me playing my own music anymore 
because of some Logic IP thing in GarageBand? Some might think the Hurdle of 
Servers or NT-based systems were better - but I havn't touched those in a long 
time.


> 
> Racket is a lot more useful because you would never get an error about an 
> unbound identifier at runtime, because it can always tell during compile time 
> whether it’s bound or not.  And this makes things like `defined?` fairly 
> useless at runtime, because that information is useful during expansion time 
> instead.  That’s why functions like identifier-binding and syntax-local-value 
> are provided.

I see ... the other link 
(http://stackoverflow.com/questions/20076868/how-to-know-whether-a-racket-variable-is-defined-or-not)
 proposed an if-defined macro/syntax-object. That's all you ever need, I guess. 
Racket's so called compile time checks are really useful and I hope they are 
available as a library to check existing source trees algorithmically? But 
sometimes I know better than the compiling stage and defined? ...


Thank you and regards,
Michael

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to