role of reserved word "method" 
Author Message
 role of reserved word "method"


down...
        Gabor

######################
Consider the following line in Dylan:

foo(method (n :: <number>) n * n end);

This is a the call of a function foo taking a bare method as an argument.

It is not fully clear to me which BNF rule allows parsing of bare methods.

"method" only appears in four places in the BNF:
- as a BEGIN-WORD
- as a DEFINE-BODY-WORD
- in local-methods
- and method-definition.

The two last are ruled out, since they contain "method" as optional and for
bare
methods "method" is obligatory.

DEFINE-BODY-WORD is ruled out because bare methods may appear not only on
toplevel.

So remains BEGIN-WORD.
This suggests that bare methods are in fact calls of a statement macro.
This is
suggested in the Draft DRM p. 168 where an example of Method macro  is
given,
with a not further detailed expansion.

Now, if bare methods are implemented by macros, then some language
construct
(some kind of lambda syntax) must exist, to which they expand. My
understanding is, that bare methods are the lambda expressions in Dylan. So
the "method" statement macro will not be a macro at all. What was the
rationale of making "method" to a BEGIN-WORD instead of a core-word?
Because it fits nicely into the statement syntax? This seems reasonable to
me. Am I right in assuming that "method" fits the statement syntax, but
should be special-cased by the implementation instead of macro-expanding
it?

Thanks in advance,

        Gabor



Sat, 22 Jul 2000 03:00:00 GMT  
 role of reserved word "method"

    Gabor> Now, if bare methods are implemented by macros, then some
    Gabor> language construct (some kind of lambda syntax) must exist,
    Gabor> to which they expand. My understanding is, that bare
    Gabor> methods are the lambda expressions in Dylan. So the
    Gabor> "method" statement macro will not be a macro at all. What
    Gabor> was the rationale of making "method" to a BEGIN-WORD
    Gabor> instead of a core-word?  Because it fits nicely into the
    Gabor> statement syntax? This seems reasonable to me. Am I right
    Gabor> in assuming that "method" fits the statement syntax, but
    Gabor> should be special-cased by the implementation instead of
    Gabor> macro-expanding it?

No. You are right that the reason for this is that "method" ought to
be a statement. Implementations are free to use whatever method they
choose to handle method statements. It is not unlikely that the
implementation is indeed a macro, but the expansion of the macro uses
non-portable and platform-specific language constructs.

This is by purpose. It simplifies the language (for the programmer,
it's just another statement), and it leaves room for the
implementation to handle it in whatever form is the most convenient
and efficient.

Andreas

--
Top ten reasons why SGI sucks, No 5:
"dbx Internal Error: Got a FatalError event in executeRPC. Giving up
 FatalError event Error code 77 serial# 5." dbx 7.1 on IRIX 6.x



Sat, 22 Jul 2000 03:00:00 GMT  
 role of reserved word "method"

Consider the following line in Dylan:

foo(method (n :: <number>) n * n end);

This is a the call of a function foo taking a bare method as an argument.

It is not fully clear to me which BNF rule allows parsing of bare methods.

"method" only appears in four places in the BNF:
- as a BEGIN-WORD
- as a DEFINE-BODY-WORD
- in local-methods
- and method-definition.

The two last are ruled out, since they contain "method" as optional and for
bare
methods "method" is obligatory.

DEFINE-BODY-WORD is ruled out because bare methods may appear not only on
toplevel.

So remains BEGIN-WORD.
This suggests that bare methods are in fact calls of a statement macro.
This is
suggested in the Draft DRM p. 168 where an example of Method macro  is
given,
with a not further detailed expansion.

Now, if bare methods are implemented by macros, then some language
construct
(some kind of lambda syntax) must exist, to which they expand. My
understanding is, that bare methods are the lambda expressions in Dylan. So
the "method" statement macro will not be a macro at all. What was the
rationale of making "method" to a BEGIN-WORD instead of a core-word?
Because it fits nicely into the statement syntax? This seems reasonable to
me. Am I right in assuming that "method" fits the statement syntax, but
should be special-cased by the implementation instead of macro-expanding
it?

Thanks in advance,

        Gabor



Sun, 23 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TABLE -- The "reserved" word

2. HLA - reserved keyword used twice ("in")

3. COBOL "reserved columns" (was: Philosophical question

4. Reserving package name "solar"

5. "methods" method

6. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

7. regex "word complement"?

8. define "variable" word

9. [Fwd: "Official" definition of Forth words]

10. "Official" definition of Forth words

11. H3sm with "compiler" words

12. Dumb "name of current word" question

 

 
Powered by phpBB® Forum Software