* Typo: .substr in pmacros.texi is .substring in pmacros.scm
@ 2002-01-28 10:57 Hans-Peter Nilsson
2002-01-28 11:05 ` Frank Ch. Eigler
0 siblings, 1 reply; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-01-28 10:57 UTC (permalink / raw)
To: cgen
Please consider applying this patch. It would IMHO be very useful
if .sym-built symbols were .pmacro-expanded, as I initially thought.
For example, a .pmacro could apply .sym on an argument and create
references to other, specialized .pmacro:s. Currently this can be
accomplished only with the apparently frowned-upon "(.eval
(pmacro-expand '(.sym arg -something)))". If you want, I guess I
can elaborate.
2002-01-28 Hans-Peter Nilsson <hp@axis.com>
* doc/pmacros.texi: Fix .substr typo to .substring.
Mention that .sym expansions are not further expanded.
Index: pmacros.texi
===================================================================
RCS file: /cvs/src/src/cgen/doc/pmacros.texi,v
retrieving revision 1.2
diff -p -c -r1.2 pmacros.texi
*** pmacros.texi 2001/03/19 03:36:24 1.2
--- pmacros.texi 2002/01/28 18:33:26
*************** Preprocessor macros provide a way of sim
*** 21,27 ****
* Convert a number to a hex:: The @code{.hex} builtin
* Convert a string to uppercase:: The @code{.upcase} builtin
* Convert a string to lowercase:: The @code{.downcase} builtin
! * Getting part of a string:: The @code{.substr} builtin
* List splicing:: The @code{.splice} builtin
* Number generation:: The @code{.iota} builtin
* Mapping a macro over a list:: The @code{.map} builtin
--- 21,27 ----
* Convert a number to a hex:: The @code{.hex} builtin
* Convert a string to uppercase:: The @code{.upcase} builtin
* Convert a string to lowercase:: The @code{.downcase} builtin
! * Getting part of a string:: The @code{.substring} builtin
* List splicing:: The @code{.splice} builtin
* Number generation:: The @code{.iota} builtin
* Mapping a macro over a list:: The @code{.map} builtin
*************** Acceptable arguments are symbols, string
*** 144,150 ****
The result is a symbol with the arguments concatenated together.
Numbers are converted to a string, base 10, and then to a symbol.
The result must be a valid Scheme symbol with the additional restriction
! that the first character must be a letter.
@node String concatenation
@section String concatenation
--- 144,151 ----
The result is a symbol with the arguments concatenated together.
Numbers are converted to a string, base 10, and then to a symbol.
The result must be a valid Scheme symbol with the additional restriction
! that the first character must be a letter. The result is not further
! expanded, regardless of whether there's a macro by that name.
@node String concatenation
@section String concatenation
*************** Example:
*** 222,232 ****
@node Getting part of a string
@section Getting part of a string
! @cindex .substr
! Extract a part of a string with @code{.substr}.
! Syntax: @code{(.substr string start end)}
where @samp{start} is the starting character, and @samp{end} is one past
the ending character. Character numbering begins at position 0.
--- 223,233 ----
@node Getting part of a string
@section Getting part of a string
! @cindex .substring
! Extract a part of a string with @code{.substring}.
! Syntax: @code{(.substring string start end)}
where @samp{start} is the starting character, and @samp{end} is one past
the ending character. Character numbering begins at position 0.
*************** string is returned.
*** 236,242 ****
Example:
@smallexample
! (.substr "howzitgoineh?" 2 6) --> "wzit"
@end smallexample
@node List splicing
--- 237,243 ----
Example:
@smallexample
! (.substring "howzitgoineh?" 2 6) --> "wzit"
@end smallexample
@node List splicing
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm
2002-01-28 10:57 Typo: .substr in pmacros.texi is .substring in pmacros.scm Hans-Peter Nilsson
@ 2002-01-28 11:05 ` Frank Ch. Eigler
2002-03-19 7:00 ` Hans-Peter Nilsson
0 siblings, 1 reply; 14+ messages in thread
From: Frank Ch. Eigler @ 2002-01-28 11:05 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
[-- Attachment #1: Type: text/plain, Size: 404 bytes --]
Hi -
On Mon, Jan 28, 2002 at 07:57:08PM +0100, Hans-Peter Nilsson wrote:
> Please consider applying this patch.
Sure - feel free to commit it if you are able.
> It would IMHO be very useful if .sym-built symbols were
> .pmacro-expanded, as I initially thought. [...]
I see this sort of recursive macro-expansion could be useful.
Does someone have an argument against it?
- FChE
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm
2002-01-28 11:05 ` Frank Ch. Eigler
@ 2002-03-19 7:00 ` Hans-Peter Nilsson
2002-03-19 8:03 ` Frank Ch. Eigler
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-19 7:00 UTC (permalink / raw)
To: cgen; +Cc: hans-peter.nilsson
> Date: Mon, 28 Jan 2002 14:05:29 -0500
> From: "Frank Ch. Eigler" <fche@redhat.com>
> On Mon, Jan 28, 2002 at 07:57:08PM +0100, Hans-Peter Nilsson wrote:
> > It would IMHO be very useful if .sym-built symbols were
> > .pmacro-expanded, as I initially thought. [...]
>
> I see this sort of recursive macro-expansion could be useful.
> Does someone have an argument against it?
I didn't see any argument against it, except for the comment in
the code. This works for my simple command-line examples
including the one in the comment but beware of the scheme/CGEN
newbie. (Is this an ok way to compose ChangeLog entries for
nested defines?)
Ok to commit?
2002-03-19 Hans-Peter Nilsson <hp@axis.com>
* pmacros.scm (-pmacro-expand,scan): If result is a symbol,
call scan-symbol on it.
Index: pmacros.scm
===================================================================
RCS file: /cvs/src/src/cgen/pmacros.scm,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 pmacros.scm
*** pmacros.scm 2000/07/28 04:11:52 1.1.1.1
--- pmacros.scm 2002/03/19 14:30:25
***************
*** 229,239 ****
((and (list? exp) (not (null? exp))) (scan-list exp))
; Not a symbol or expression, return unchanged.
(else exp))))
! ; ??? We use to re-examine `result' to see if it was another pmacro
! ; invocation. This allowed doing things like ((.sym a b c) arg1 arg2)
! ; where `abc' is a pmacro. Scheme doesn't work this way, so it was
! ; removed. It can be put back should it ever be warranted.
! result))
(if -pmacro-trace?
(begin
--- 229,239 ----
((and (list? exp) (not (null? exp))) (scan-list exp))
; Not a symbol or expression, return unchanged.
(else exp))))
! ; Re-examining `result' to see if it is another pmacro invocation
! ; allows doing things like ((.sym a b c) arg1 arg2)
! ; where `abc' is a pmacro. Scheme doesn't work this way, but then
! ; this is CGEN.
! (if (symbol? result) (scan-symbol result) result)))
(if -pmacro-trace?
(begin
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm
2002-03-19 7:00 ` Hans-Peter Nilsson
@ 2002-03-19 8:03 ` Frank Ch. Eigler
2002-03-19 8:14 ` Doug Evans
2002-03-19 8:15 ` Typo: .substr in pmacros.texi is .substring in pmacros.scm Doug Evans
2 siblings, 0 replies; 14+ messages in thread
From: Frank Ch. Eigler @ 2002-03-19 8:03 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
[-- Attachment #1: Type: text/plain, Size: 509 bytes --]
Hi -
> > I see this sort of recursive macro-expansion could be useful.
> > Does someone have an argument against it?
>
> I didn't see any argument against it [...]
Right.
> Ok to commit?
Sure, thanks.
> 2002-03-19 Hans-Peter Nilsson <hp@axis.com>
>
> * pmacros.scm (-pmacro-expand,scan): If result is a symbol,
> call scan-symbol on it.
The ChangeLog entry is of fine form, though I might add
... , to enable recursive macro-expansion.
- FChE
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm
2002-03-19 7:00 ` Hans-Peter Nilsson
2002-03-19 8:03 ` Frank Ch. Eigler
@ 2002-03-19 8:14 ` Doug Evans
2002-03-19 12:19 ` Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm) Hans-Peter Nilsson
2002-03-19 8:15 ` Typo: .substr in pmacros.texi is .substring in pmacros.scm Doug Evans
2 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2002-03-19 8:14 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> > Date: Mon, 28 Jan 2002 14:05:29 -0500
> > From: "Frank Ch. Eigler" <fche@redhat.com>
>
> > On Mon, Jan 28, 2002 at 07:57:08PM +0100, Hans-Peter Nilsson wrote:
> > > It would IMHO be very useful if .sym-built symbols were
> > > .pmacro-expanded, as I initially thought. [...]
> >
> > I see this sort of recursive macro-expansion could be useful.
> > Does someone have an argument against it?
>
> I didn't see any argument against it, except for the comment in
> the code. This works for my simple command-line examples
> including the one in the comment but beware of the scheme/CGEN
> newbie. (Is this an ok way to compose ChangeLog entries for
> nested defines?)
>
> ! ; ??? We use to re-examine `result' to see if it was another pmacro
> ! ; invocation. This allowed doing things like ((.sym a b c) arg1 arg2)
> ! ; where `abc' is a pmacro. Scheme doesn't work this way, so it was
> ! ; removed. It can be put back should it ever be warranted.
I'm apprehensive, but if people want to try this go ahead.
If people start getting into trouble because of this I hope they share their
experience.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm
2002-03-19 7:00 ` Hans-Peter Nilsson
2002-03-19 8:03 ` Frank Ch. Eigler
2002-03-19 8:14 ` Doug Evans
@ 2002-03-19 8:15 ` Doug Evans
2 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2002-03-19 8:15 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> I didn't see any argument against it, except for the comment in
> the code. This works for my simple command-line examples
> including the one in the comment but beware of the scheme/CGEN
> newbie. (Is this an ok way to compose ChangeLog entries for
> nested defines?)
btw, do you have an actual use for it?
Or is this just something that you think might be
useful in the future?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 8:14 ` Doug Evans
@ 2002-03-19 12:19 ` Hans-Peter Nilsson
2002-03-19 12:24 ` Doug Evans
0 siblings, 1 reply; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-19 12:19 UTC (permalink / raw)
To: dje; +Cc: hans-peter.nilsson, cgen
> From: Doug Evans <dje@transmeta.com>
> Date: Tue, 19 Mar 2002 08:14:02 -0800 (PST)
> Hans-Peter Nilsson writes:
> > > Date: Mon, 28 Jan 2002 14:05:29 -0500
> > > From: "Frank Ch. Eigler" <fche@redhat.com>
> >
> > > On Mon, Jan 28, 2002 at 07:57:08PM +0100, Hans-Peter Nilsson wrote:
> > > > It would IMHO be very useful if .sym-built symbols were
> > > > .pmacro-expanded, as I initially thought. [...]
> > >
> > > I see this sort of recursive macro-expansion could be useful.
> > > Does someone have an argument against it?
> >
> > I didn't see any argument against it, except for the comment in
> > the code. This works for my simple command-line examples
> > including the one in the comment but beware of the scheme/CGEN
> > newbie. (Is this an ok way to compose ChangeLog entries for
> > nested defines?)
> >
> > ! ; ??? We use to re-examine `result' to see if it was another pmacro
> > ! ; invocation. This allowed doing things like ((.sym a b c) arg1 arg2)
> > ! ; where `abc' is a pmacro. Scheme doesn't work this way, so it was
> > ! ; removed. It can be put back should it ever be warranted.
>
> I'm apprehensive, but if people want to try this go ahead.
Hey, time has run out for protests! :-)
> If people start getting into trouble because of this I hope they share their
> experience.
And their joy! But that would probably be a first. ;-)
> From: Doug Evans <dje@transmeta.com>
> Date: Tue, 19 Mar 2002 08:14:59 -0800 (PST)
> btw, do you have an actual use for it?
> Or is this just something that you think might be
> useful in the future?
As I wrote, I had already startet to depend upon it in a port in
progress. I greatly simplified things (or made it hard in the
absence, I should say).
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 12:19 ` Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm) Hans-Peter Nilsson
@ 2002-03-19 12:24 ` Doug Evans
2002-03-19 13:20 ` Hans-Peter Nilsson
0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2002-03-19 12:24 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> As I wrote, I had already startet to depend upon it in a port in
> progress. I greatly simplified things (or made it hard in the
> absence, I should say).
Note that there are otherways to do this, besides the implicit re-lookup.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 12:24 ` Doug Evans
@ 2002-03-19 13:20 ` Hans-Peter Nilsson
2002-03-19 13:24 ` Doug Evans
0 siblings, 1 reply; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-19 13:20 UTC (permalink / raw)
To: dje; +Cc: hans-peter.nilsson, cgen
> From: Doug Evans <dje@transmeta.com>
> Date: Tue, 19 Mar 2002 12:24:36 -0800 (PST)
> Cc: cgen@sources.redhat.com
> Hans-Peter Nilsson writes:
> > As I wrote, I had already startet to depend upon it in a port in
> > progress. I greatly simplified things (or made it hard in the
> > absence, I should say).
>
> Note that there are otherways to do this, besides the implicit re-lookup.
I'm totally blank (what "this"?) I generally want to map a
pmacro on a list defined as a pmacro, generating calls to other
pmacros. How can I do that without re-lookup?
(define-pmacro x (a b c))
(define-pmacro (do-a y) (+ y 1))
(define-pmacro (do-b y) (- y 1))
(define-pmacro '(do-c y) (* y 2))
(pmacro-expand '(.map (.pmacro (z) ((.sym code- z) ((.sym do- z) w))) x))
=> ((code-a (+ w 1)) (code-b (- w 1)) (code-c (* w 2)))
Hmm, maybe that didn't come out clear. Tell me if you feel you
need something better.
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 13:20 ` Hans-Peter Nilsson
@ 2002-03-19 13:24 ` Doug Evans
2002-03-19 13:53 ` Hans-Peter Nilsson
0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2002-03-19 13:24 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> > Note that there are otherways to do this, besides the implicit re-lookup.
>
> How can I do that without re-lookup?
^
^
You left out the "implicit".
e.g. what's the opposite of implicit? [hint hint]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 13:24 ` Doug Evans
@ 2002-03-19 13:53 ` Hans-Peter Nilsson
2002-03-19 14:47 ` Doug Evans
0 siblings, 1 reply; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-19 13:53 UTC (permalink / raw)
To: dje; +Cc: hans-peter.nilsson, cgen
> From: Doug Evans <dje@transmeta.com>
> Date: Tue, 19 Mar 2002 13:24:48 -0800 (PST)
> Hans-Peter Nilsson writes:
> > > Note that there are otherways to do this, besides the implicit re-lookup.
> >
> > How can I do that without re-lookup?
> ^
> ^
> You left out the "implicit".
> e.g. what's the opposite of implicit? [hint hint]
Ah, you mean I should use (.eval (pmacro-expand '(.sym ...)))!
But that's frowned upon (pmacros.scm) (supposedly because you
break through the CGEN description interface into scheme and
nasty things not accounted for can happen):
; .eval is an experiment. Ports that consider themselves to be of beta
; quality or better don't use it.
Besides, I *expected* implicit re-lookup of a symbol built-up
from (.sym ...). I think it comes naturally: what happens to
abc should happen to the expansion of (.sym a b c). If people
don't want re-lookup, may there can be added explicit deferring,
by, say, (quote ...) ;-)
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 13:53 ` Hans-Peter Nilsson
@ 2002-03-19 14:47 ` Doug Evans
2002-03-20 11:15 ` Hans-Peter Nilsson
0 siblings, 1 reply; 14+ messages in thread
From: Doug Evans @ 2002-03-19 14:47 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> > You left out the "implicit".
> > e.g. what's the opposite of implicit? [hint hint]
>
> Ah, you mean I should use (.eval (pmacro-expand '(.sym ...)))!
Almost, but not quite. I can see why that might be one's first guess.
> But that's frowned upon (pmacros.scm) (supposedly because you
> break through the CGEN description interface into scheme and
> nasty things not accounted for can happen):
>
> ; .eval is an experiment. Ports that consider themselves to be of beta
> ; quality or better don't use it.
.eval has connotations far beyond the problem at hand.
> Besides, I *expected* implicit re-lookup of a symbol built-up
> from (.sym ...). I think it comes naturally: what happens to
> abc should happen to the expansion of (.sym a b c). If people
> don't want re-lookup, may there can be added explicit deferring,
> by, say, (quote ...) ;-)
Let's wait and see what, if any, kinds of problems this causes.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-19 14:47 ` Doug Evans
@ 2002-03-20 11:15 ` Hans-Peter Nilsson
2002-03-22 9:11 ` Doug Evans
0 siblings, 1 reply; 14+ messages in thread
From: Hans-Peter Nilsson @ 2002-03-20 11:15 UTC (permalink / raw)
To: dje; +Cc: hans-peter.nilsson, cgen
> From: Doug Evans <dje@transmeta.com>
> Date: Tue, 19 Mar 2002 14:47:07 -0800 (PST)
> Hans-Peter Nilsson writes:
> > > You left out the "implicit".
> > > e.g. what's the opposite of implicit? [hint hint]
> >
> > Ah, you mean I should use (.eval (pmacro-expand '(.sym ...)))!
>
> Almost, but not quite. I can see why that might be one's first guess.
I'm too dense. Please spell it out.
brgds, H-P
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm)
2002-03-20 11:15 ` Hans-Peter Nilsson
@ 2002-03-22 9:11 ` Doug Evans
0 siblings, 0 replies; 14+ messages in thread
From: Doug Evans @ 2002-03-22 9:11 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: cgen
Hans-Peter Nilsson writes:
> > From: Doug Evans <dje@transmeta.com>
> > Date: Tue, 19 Mar 2002 14:47:07 -0800 (PST)
>
> > Hans-Peter Nilsson writes:
> > > > You left out the "implicit".
> > > > e.g. what's the opposite of implicit? [hint hint]
> > >
> > > Ah, you mean I should use (.eval (pmacro-expand '(.sym ...)))!
> >
> > Almost, but not quite. I can see why that might be one's first guess.
>
> I'm too dense. Please spell it out.
Later on I thought I said enough to indicate what I was getting at.
Sorry.
> > .eval has connotations far beyond the problem at hand.
i.e. Don't call it .eval. Call it something else.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2002-03-22 17:11 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-28 10:57 Typo: .substr in pmacros.texi is .substring in pmacros.scm Hans-Peter Nilsson
2002-01-28 11:05 ` Frank Ch. Eigler
2002-03-19 7:00 ` Hans-Peter Nilsson
2002-03-19 8:03 ` Frank Ch. Eigler
2002-03-19 8:14 ` Doug Evans
2002-03-19 12:19 ` Recursive expansion of pmacros (was: Re: Typo: .substr in pmacros.texi is .substring in pmacros.scm) Hans-Peter Nilsson
2002-03-19 12:24 ` Doug Evans
2002-03-19 13:20 ` Hans-Peter Nilsson
2002-03-19 13:24 ` Doug Evans
2002-03-19 13:53 ` Hans-Peter Nilsson
2002-03-19 14:47 ` Doug Evans
2002-03-20 11:15 ` Hans-Peter Nilsson
2002-03-22 9:11 ` Doug Evans
2002-03-19 8:15 ` Typo: .substr in pmacros.texi is .substring in pmacros.scm Doug Evans
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).