Is there any well-known implementation of a macro similar to old Lisp Machine's defsubst, but not as fancy, one that simply emits a macro after doing a reasonable, if less than perfect, attempt to do substitutions and guarantee first-to-last arg once-and-once-only evaluation?
I realize that most people just use declare inline for this kind of thing. Or define a macro like defsubst just to emit a defun with a declare-inline declaration. I would like something that's different: something that always emits a macro def given a function-like semantics for args and body.
It's a pretty simple thing, but I was wondering if it's sitting around in a library somewhere. What's out there?
Thanks,
Mark
On Sep 21, 2010, at 10:48, Mark H. David wrote:
Is there any well-known implementation of a macro similar to old Lisp Machine's defsubst, but not as fancy, one that simply emits a macro after doing a reasonable, if less than perfect, attempt to do substitutions and guarantee first-to-last arg once-and-once-only evaluation?
I realize that most people just use declare inline for this kind of thing. Or define a macro like defsubst just to emit a defun with a declare-inline declaration. I would like something that's different: something that always emits a macro def given a function- like semantics for args and body.
It's a pretty simple thing, but I was wondering if it's sitting around in a library somewhere. What's out there?
Isn't this what symbol-macrolet, macrolet, and define-compiler-macro are for?
Dr. David McClain Chief Technical Officer Refined Audiometrics Laboratory 4391 N. Camino Ferreo Tucson, AZ 85750
email: dbm@refined-audiometrics.com phone: 1.520.390.3995 web: http://refined-audiometrics.com
How is this different from using an "inline" declaration?
Mark H. David wrote:
Is there any well-known implementation of a macro similar to old Lisp Machine's defsubst, but not as fancy, one that simply emits a macro after doing a reasonable, if less than perfect, attempt to do substitutions and guarantee first-to-last arg once-and-once-only evaluation?
I realize that most people just use declare inline for this kind of thing. Or define a macro like defsubst just to emit a defun with a declare-inline declaration. I would like something that's different: something that always emits a macro def given a function-like semantics for args and body.
It's a pretty simple thing, but I was wondering if it's sitting around in a library somewhere. What's out there?
Thanks,
Mark
pro mailing list pro@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/pro
On Wed, Sep 22, 2010 at 17:18, Daniel Weinreb dlw@itasoftware.com wrote:
How is this different from using an "inline" declaration?
Some compilers ignore inline declarations. With defsubst, you are not at the mercy of the compiler. I have used defsubst (Allegro CL has it) in places where I was absolutely sure that inlining was the right thing to do. Then again, Allegro CL had me do that because it ignores inline declarations, so the whole thing may be a non-issue with other compilers.
-Hans
This is different from inlining in that does not generate a function. You cannot funcall the defined symbol, just use it as a macro. Call sites always macro-expand. I don't really care about or want to really get into a discussion of what compilers do or not, or whether this is "useful" or not. Just wondering if this is some available functionality. E.g., is the Allegro thing contributed to the world, or just proprietary?
Thanks,
Mark
Hans Hübner wrote:
On Wed, Sep 22, 2010 at 17:18, Daniel Weinrebdlw@itasoftware.com wrote:
How is this different from using an "inline" declaration?
Some compilers ignore inline declarations. With defsubst, you are not at the mercy of the compiler. I have used defsubst (Allegro CL has it) in places where I was absolutely sure that inlining was the right thing to do. Then again, Allegro CL had me do that because it ignores inline declarations, so the whole thing may be a non-issue with other compilers.
-Hans
On Wed, Sep 22, 2010 at 17:32, Mark H. David mhd@yv.org wrote:
This is different from inlining in that does not generate a function. You cannot funcall the defined symbol, just use it as a macro. Call sites always macro-expand. I don't really care about or want to really get into a discussion of what compilers do or not, or whether this is "useful" or not. Just wondering if this is some available functionality. E.g., is the Allegro thing contributed to the world, or just proprietary?
The Allegro CL defsubst is not open source, it is not even part of the documented ACL API. I am not aware of any open source implementations, but I'd be interested.
-Hans
Can someone show an example of this defsubst in use? I'm not sure I understand what it's for.
-Peter
On Wed, Sep 22, 2010 at 9:08 AM, Hans Hübner hans.huebner@gmail.com wrote:
On Wed, Sep 22, 2010 at 17:32, Mark H. David mhd@yv.org wrote:
This is different from inlining in that does not generate a function.
You cannot funcall the
defined symbol, just use it as a macro. Call sites always macro-expand.
I don't really care
about or want to really get into a discussion of what compilers do or
not, or whether this
is "useful" or not. Just wondering if this is some available
functionality. E.g., is the Allegro
thing contributed to the world, or just proprietary?
The Allegro CL defsubst is not open source, it is not even part of the documented ACL API. I am not aware of any open source implementations, but I'd be interested.
-Hans
pro mailing list pro@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/pro
On 22 September 2010 19:16, Peter Seibel peter@gigamonkeys.com wrote:
Can someone show an example of this defsubst in use? I'm not sure I understand what it's for.
To the best of my understanding it has two effects:
1. it allows reliable inlining on compilers that do not respect inline declarations.
2. it allows the expansion to utilize the lexical context of the call site.
Consider:
(defmacro foo () :global)
(declaim (inline bar1)) (defun bar1 () (foo))
(defsubst bar2 () (foo))
(macrolet ((foo () :local)) (values (bar1) (bar2))) => :GLOBAL, :LOCAL
Cheers,
-- Nikodemus
On Wed, 22 Sep 2010 17:24:33 +0200, Hans Hübner hans.huebner@gmail.com wrote:
On Wed, Sep 22, 2010 at 17:18, Daniel Weinreb dlw@itasoftware.com wrote:
How is this different from using an "inline" declaration?
Some compilers ignore inline declarations. With defsubst, you are not at the mercy of the compiler. I have used defsubst (Allegro CL has it) in places where I was absolutely sure that inlining was the right thing to do.
This all reminds me of the old lkml glory:
http://markmail.org/message/uaegqp4xznxupctd
The "inline_me_harder" one is my personal favorite.