Arc Forumnew | comments | leaders | submitlogin
1 point by CatDancer 6114 days ago | link | parent

I'm bemused that calling a function fixes in which lexical environment the functions it calls come from. Probably not something I want to use for my (emergency-shutdown) function, hmm? Or do I ensure that the functions that emergency-shutdown calls are fixed to a particular lexicon by, er, writing some other functions that call them and then calling them? But then there's the (turn-power-off) function that (emergency-shutdown) calls...


1 point by nlavine 6113 days ago | link

I'm not sure I quite understand this, but let me see if I can help clear up the confusion anyway.

A function, as distinct from a macro, has the property that when you call it, it will work the same way every time, even if you have provided some crazy bindings that shadow the functions it calls. For instance,

  (def prn args ; from arc.arc
    (do1 (apply pr args)
         (writec #\newline))

  (let pr (die)
    (prn 53)) ; doesn't die.
Hygienic macros work the same way.

Non-hygienic macros do not have this property. That is the basic issue.

(Note: your definition of hygiene may vary. In fact, mine might too; who knows?)

-----

1 point by eds 6113 days ago | link

Don't you mean

  (let pr [die]
    (prn 53)) ; doesn't die.
Otherwise it dies in binding pr to (die) and doesn't even get to (prn 53).

-----

1 point by nlavine 6113 days ago | link

Yeah. I didn't really have a clear definition for die. That's probably better.

I don't seem to be able to edit it now, though, so I'm afraid it will have to stay the bad way.

-----