Re: Runtime macros



Coby Beck wrote:
"Randall Randall" <randall@xxxxxxxxxxxxxxxxxx> wrote in message news:42bedf36$1_4@xxxxxxxxxxxxxxxxxxxxx

be a static type to the programmer). Runtime macros with optional
replacement would allow DEFUN forms, for example, to register the "function"
as a macro rather than a function, and at runtime, the macro could examine
the actual arguments it got, in addition to their names, and provide
appropriate declarations in its output, and then ask the compiler to
replace it with the function in question. The programmer need not write
declarations again (except for those cases where it wouldn't be possible
to figure out the proper declaration from a single example), and yet,


It seems to me this last qualification dooms your idea in the way I was about to try to explain!

"dooms?" :)

When is a single example *ever* going to tell you what to expect everytime? ISTM, if there are cases where you as a programmer can know that the first type seen indicates it is always that type that that can only be an artifact of some implementation detail about your whole system, eg harware, or third party code etc.

Is it really the case that most people write most functions such that they can either take, for example, an integer, cons, or array for a given argument? I would expect to use CLOS methods for that, in CL, but maybe I'm odd.

If this is the case, you should be able to determine these things at complile time.

People talk about how smart the OCaml compiler is for being able to determine *many* of these things at compile time, so my assumption is that it's hard to do. If there's some simple way to do it without actually inspecting the values received, then the example is, as you say, pointless.

If it really must wait til runtime, then just delay compilation until then (which is all you are doing in a round-about way with your plan anyway).

Well, and adding a choice about whether to compile finally or repeatedly.

You could have a special defun type form that checks if it has yet been called, if this is the first time, check the types of its arguments, put the declarations into the body of its code, compile it and them setf the symbol-function so that next time it just proceeds.

It's true that that's an alternative way of doing the example use of what I was talking about. I'll have to think about it some more.

--
Randall Randall <randall@xxxxxxxxxxxxxxxxxx>


.



Relevant Pages

  • Re: How to pass information, classes between forms in Windows Application mode [ FINALLY!]
    ... In a WinForms app generated by Visual Studio, ... A constructor in my "book" is the stuff that appears in public ... wouldn't compile as the appropriate constructor signature hasn't been ... declarations, it will compile. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: modifying array access syntax
    ... I published recent speculation on the ARRAY ... > are in fact remnants of the property lists of these Lisp-N ... these that were meaningful at compile time (FEXPR, FSUBR, and MACRO ...
    (comp.lang.lisp)
  • Re: Localized Parameter Directive?
    ... In fact there are 10 or 20 API declarations ... > Using RadASM which in turn is using MASM to compile. ... > invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT ... > WinMain endp ...
    (alt.lang.asm)
  • Re: managing header files
    ... hundred by commenting out some external declarations, ... complaints) but the complaints about redundant declarations and the complaints ... to simplify the problem I decided to just try to compile ... approach of, in effect, finding one header file that all the .c files ...
    (comp.lang.c.moderated)
  • Re: DISFAVORED Was: name for 3 PICK finally?
    ... complexity is reduced by reducing the phases of execution to keep ... outside happens when the word containing the macro executes. ... LITERAL COMPILE, .... ... ``GET LITERAL @ LITERAL `EXECUTE COMPILE,'' ...
    (comp.lang.forth)

Loading