[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Formal Response #382: Allow "if" to accept arbitrarily many if-then pairs



Earlier today, John Boyle wrote:
> [...]
> 
> As you show, it is possible to define "if" to be used at
> compile-time, but this is not satisfactory because the macros I
> proceed to define, using if, will not be usable at compile-time to
> define a third set of macros.  I could (for-syntax <define the
> second set of macros>), which would make them available at
> compile-time, but that would not succeed because "if" does not have
> the right definition at phase 2 (used when defining macros for
> compile-time).  This could be fixed by (for-syntax (for-syntax
> <define if the way I want>)).  However, if I wanted to define more
> macros that depended on the third set, I would need to (for-syntax
> (for-syntax <define second set of macros>)), and (for-syntax
> (for-syntax (for-syntax <define if>))).  And so on.  I considered
> some schemes like defining a "define-macro" procedure that would
> write all previous definitions to a file and require it
> (for-syntax), but decided this was getting ridiculous--these are the
> insane workarounds I mentioned.

There's no need for that -- you can just use one definition and put it
in a file:

  #lang racket/base
  (provide (except-out (all-from-out racket/base) if)
           (rename-out [my-if if]))
  (define-syntax my-if ...)

And then you just `require' that one file into any level that you
need.  This is just like using `racket/base' which doesn't give you
any real language at the macro level so you explicitly prefix the code
with a (require (for-syntax racket/base)) -- you'll get the same
thing, only using your own language like that.


Earlier today, John Boyle wrote:
> [...] (There are still two namespaces, but that can be dealt
> with--at worst, using binding and assignment constructs that affect
> both namespaces.)

That's a very dangerous path.  You'll need to redefine huge parts of
the language.  For example, if you add some `define' macro that does
both `defun' and `defvar', you still get weird behavior when you use
`let'.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports