COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Macro dependency tracking

• Email
• Follow

Hi,

I always wondered why macro calls are not reexpanded automatically each
time the macro is redefined. Whenever I recompile a macro definition I
should recompile all places where the macro was expanded which is
sometimes nearly impossible to do, so it's easier to restart and
recompile everything.

This is an incomplete and simple implementation to automatically
recompile functions using the computed-class package at
http://common-lisp.net/project/computed-class

The idea is that each function and macro definition will have it's own
computed-state and the dependency will be tracked automatically during
compiling a function at macroexpand time.

Each time a macro is redefined it will invalidate the computed-states
of the functions where it was used. Whenever a function is called it
will first check if the function needs to be recompiled. This runtime
overhead can be eliminated, see later.

Ok, don't take this too seriously, but still it might be interesting
how short it is...

CC> (define-computed-universe mdt-compute-as)
MDT-COMPUTE-AS

CC> (defmacro defun/mdt (name args &body forms)
(clet ((f (mdt-compute-as
(progn
(format t "Recompiling ~A" ',name)
(compile nil (lambda ,',args ,',@forms))))))
(defun ,name ,args
(funcall f ,@args))))
DEFUN/MDT

CC> (defmacro defmacro/mdt (name args &body forms)
(let ((m (or (get name 'mdt)
(setf (get name 'mdt) (mdt-compute-as nil)))))
(invalidate-computed-state m)
(defmacro ,name ,args
(computed-state-value (get ',name 'mdt))
,@forms)))
DEFMACRO/MDT

CC> (defmacro/mdt with-a (&body forms)
(let ((a 1))
,@forms))
WITH-A

(with-a
(+ a b)))

2

2

CC> (defmacro/mdt with-a (&body forms)
(let ((a 2))
,@forms))
WITH-A

3

3

Unfortunately there is no forward invalidation in the computed class
package yet, so there is an extra runtime check each time the function
add is called whether it has to be recompiled or not. This can be
easily fixed by the following definition as soon as forward
invalidation becomes available.

(defmacro defun/mdt* (name args &body forms)
(computed-state-value
(mdt-compute-as
(progn
(format t "Recompiling ~A" ',name)
(defun ,name ,args
,@forms)))))

The function's computed state will be captured by the macros' computed
states as the compiler expands macro calls. If there were no macro
calls at all then the function's computed state will be garbage
collected. Whenever a called macro definition changes its computed
state gets invalidated and thus the functions depending on it will be
immediately redefined.

Cheers,
levy


 0
Reply levente.meszaros (36) 12/20/2006 9:14:29 PM

See related articles to this posting


levy wrote:
> Hi,
>
> I always wondered why macro calls are not reexpanded automatically each
> time the macro is redefined. Whenever I recompile a macro definition I
> should recompile all places where the macro was expanded which is
> sometimes nearly impossible to do, so it's easier to restart and
> recompile everything.
>
> This is an incomplete and simple implementation to automatically
> recompile functions using the computed-class package at
> http://common-lisp.net/project/computed-class
>

Yes, and this marks quite a milestone with the number of Cells spin-offs
now exceeding the number of users.

Similarly, I never thought my failure to document could be surpassed,
but here is the computed-class documentation:

> See test.lisp for more examples and/or read the Cells docs.

I underestimated you yobs.

:)

ken

 0
Reply kentilton (2985) 12/20/2006 9:50:10 PM

Ken Tilton wrote:
> Yes, and this marks quite a milestone with the number of Cells spin-offs
> now exceeding the number of users.
Count me to the users too, at least for some time!

> > See test.lisp for more examples and/or read the Cells docs.
Well, what can I say... ;-)

The point is not comparison but that the compiler, CLOS mop or a
structured editor could use stuff like that.

Cheers,
levy


 0
Reply levente.meszaros (36) 12/20/2006 10:02:00 PM


levy wrote:
> Ken Tilton wrote:
>
>>Yes, and this marks quite a milestone with the number of Cells spin-offs
>>now exceeding the number of users.
>
> Count me to the users too, at least for some time!
>
>
>>>See test.lisp for more examples and/or read the Cells docs.
>
> Well, what can I say... ;-)
>
> The point is not comparison but that the compiler, CLOS mop or a
> structured editor could use stuff like that.

No argument there. Hell, Cells once had (and I think someday will have
again) the moral equivalent of a Gosub, using itself a Cell to know when
to "return".

Have you heard about the annual conference for dataflow hacks? Trying to
keep talks shorter and more memorable. All must be written in the form
of substitute lyrics to popular songs and sung karoake-style. Words to
the chorus should be distributed beforehand so the audience can sing
along. Venues must be cities with casinos.

ken

--
Algebra: http://www.tilton-technology.com/LispNycAlgebra1.htm

"Well, I've wrestled with reality for thirty-five
years, Doctor, and I'm happy to state I finally
won out over it." -- Elwood P. Dowd

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon

 0
Reply kentilton (2985) 12/20/2006 10:19:01 PM

3 Replies
53 Views

Similar Articles

12/11/2013 3:46:42 PM
[PageSpeed]

Similar Artilces:

macro to define other macros

passing macro as argument to a macro
I would like to know how to have a macro expanded when passed as an argument to another macro. For example, (defmacro cond-clause (expr res) (,expr (push ,res res))) (macroexpand-1 '(cond-clause (= c 8) 1)) returns ((= C 8) (PUSH 1 RES)) but (defmacro test (expr) (cond ,expr)) (macroexpand-1 '(test (cond-clause (= c 8) 1))) returns (COND (COND-CLAUSE (= C 8) 1)) what i want it to return is (COND ((= C 8) (PUSH 1 RES))) is this possible? nmarceli@umich.edu wrote: > I would like to know how to have a macro expanded when passed as an argument &...

EQ2 Macros... Everquest 2 Macros...
I have a site up that helps people find macros, if you don't like macros plse don't flame, many of us do. The site is http://www.macromagic.tk or http://macromagic.250free.com Soon I will be posting some World of Warcraft Macros and Star Wars Galaxies Macros ...

dependencies
Can someone point me in the right direction to take the dependencies out of the following code ? for (i=0; i < m; i++) { n1 = n2; n2 = n2 + n2; e = -6.283185307179586/n2; a = 0.0; for (j=0; j < n1; j++) { c = cos(a); s = sin(a); a = a + e; for (k=j; k < n; k=k+n2) { { t1 = c*x[k+n1] - s*y[k+n1]; t2 = s*x[k+n1] + c*y[k+n1]; x[k+n1] = x[k] - t1; y[k+n1] = y[k] - t2; x[k] = x[k] + t1; y[k] = y[k] + t2; } } } } -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp...

Tracking
Hi All, I am new to networking. Want to know whether there is any utility/tool/manual way to check whether : 1. Your PC is behind firewall and if yes which firewalls 2. Your PC is remotely tracked/accessed 3. Your internet conection is through proxy or direct Please let me know. Best Regards, Synize. nilesh.kulkarni@mail.com 1) To find out if you are behind a firewall, 1st you need to know what type of internet connection you have eg. dial up / dsl. and how it gets to your computer - pci card, usb modem, eithernet, nat / network router. Next go to http://www.grc.com/x/ne.dll?rh1dkyd2 and...

what do closures, macro, and continuations do? why clisp macro special?
paul graham said clisp macro are special because data and operations are treate same in lists unlike scheme etc. What are continuations? closures? macros? lazy evaluation? monads? in few words? what power do they offer? "gavino" <bootiack@yahoo.com> writes: > paul graham said clisp macro are special because data and operations > are treate same in lists unlike scheme etc. > > What are continuations? > closures? > macros? > lazy evaluation? > monads? > > > in few words? > > what power do they offer? You serriously need to stop and t...

Read-macros, macros, dynamic binding, and evaluation.
Hello everybody, I have created a cute little DSL with the help of SET-MACRO-CHARACTER and and friends. As an example in this post, I bind sqare-brackets to read s-expressions. This is just for simplicity: (defun bind-sexpr-to-brackets () (set-syntax-from-char #\] #\)) (set-macro-character #$#'(lambda (stream char) (declare (ignore char)) (read-delimited-list #$ stream t)))) This works fine when reading a whole file or something: (defun read-from-stream-with-syntax-extensions (stream) ...

Re: Explanation of macros; Haskell macros #2
{newsgroup list trimmed} >> "Anton van Straaten" <anton@appsolutions.com> writes: > >>>Yes, but the point is that with a concise syntax for lambda, entire >>>classes of macros can become unnecessary. That's how Smalltalk >>>handles 'if', for example - no macros or special forms needed. I keep hearing good (or at least interesting) things about Smalltalk. But back when I looked at it, I was really unimpressed by its community. The mood is generally like "Yeah, Smalltalk is dead, let's finish the projects we are working...

Help using the %do_over macro from the Macro Array Package
I am trying to use the %do_over macro from the Macro Array Package (http://www.sascommunity.org/wiki/Macro_Array_Package). It works fine unless I add 2 or more statements in the "phrase" section, where one of those statements is dependent on the other. For example, the program below doesn't work, because vbar is dependent on proc gchart, and SAS doesn't seem to recognise that the two different statements are connected to each other once they are inside the "phrase" section. For example, in the program below the first chart is created because it is cerated ...

Lectures: Code walkers, questioning macros, compiler macros
Some of us might be interested in a series of lectures given last week. - Code walkers - Questioning macros - Teaching your compiler how to optimize your functions http://alu.cliki.net/lisp-user-meeting-amsterdam-april-2004 tayss_temp2@yahoo.com (Tayssir John Gabbour) wrote in message news:<866764be.0405052006.478e59da@posting.google.com>... > Some of us might be interested in a series of lectures given last week. > > - Code walkers > - Questioning macros > - Teaching your compiler how to optimize your functions > > http://alu.cliki.net/lisp-user-meeting-amsterd...

What is the option in Macro to display ERROR message if macro variable is not Resolved
Hi all, The code is : options sgen; %let one = two; %let two = three; %let three = four; %let four = last; %put &&&&&last; Output is : 357 %put &&&&&last; SYMBOLGEN: && resolves to &. SYMBOLGEN: && resolves to &. SYMBOLGEN: && resolves to &. SYMBOLGEN: && resolves to &. WARNING: Apparent symbolic reference LAST not resolved. &last Now i want, if SAS doesn't find the Macro variable "last" then instead of WARNING:, it should display ERROR: message and it shoul...

iMovie: separating one stereo track into two mono tracks
I imported a DV clip into iMovie 3. The clip has one video track and one stereo audio track. I would to separate the two channels of the audio track into two separate tracks, one for the left and the other for the right. Is there any way I can do this within iMovie? I'm willing to buy a plug-in if necessary. ) Select the clip that you wish to extract the audio from by clicking on it. 2) Go to Advanced and then Extract Audio 3) If its stereo the extracted audio appears in track 1 and 2 of the Timeline Viewer. 4) The audio can now be edited (repositioned or cropped) -- Brian Alves...

Re: Macro Variable w. Another Macro Variable in name #3
Does the following describe what you are now trying to do? %macro testidea; %let myarray=XX XY YY; %do i=1 %to 3; %let s0=%scan(&myarray,&i); %let count&s0=0; %put &&count&s0; %let count&s0=%sysevalf(&&count&s0+1); %put &&count&s0; %end; %mend; %testidea HTH, Art --------- On Fri, 19 Jan 2007 08:14:41 -0600, OR Stats <stats112@GMAIL.COM> wrote: >Hi Arthur and all, > >It's getting closer thankfully. The code below works. However, when I try >to make this macro variable (that has another ma...

sync MIDI track to audio track with 'human feel' timing
Hello, I'm a guitarist. I'm new to recording music on a computer. I'm playing with Apple Logic Express. What I'm trying to do is record a song as I play it on guitar with with 'human feel' timing (no metronome) and use that as basis for a composition. The problem is how do I sync midi percussion tracks to the looser timing of the guitar track? Thanks, -- Bart ...

Re: Defining SAS-macros in config- or autoexec-file + sharing macros between platforms
> From: Jesper Sahner > What is the exact difference between defining your macros in > the SAS-config file like this: > > -SET SASAUTOS ( > "!sasroot\core\sasmacro" .... > "!sasext0\stat\sasmacro" > "!sasext0\webhound\sasmacro" > ) > > - or defining the macros in the autoexec-file like this: > > filename x1 '...'; > filename x2 '...'; > options sasautos=(x1 x2 sasautos); no major access difference that's not what I use because I want m...

Can one track a change in filed data tracked who chaged a field value?
Have several fields on a layout that I want to track modifications to each field, not just a record. I only need the most current change, not every change. For example, Filed A conntains "Yes". If some deletes the "Yes"" value or changes it to "No" is there a way to automatically (through a calculation or script) determine this and then capture the user that changed the data perhaps using the Get (Account Name) function? Thanks is advance. Bubba wrote: >Have several fields on a layout that I want to track modifications to each >field, not ju...

How do people convert many tracks of CD to Midi, all tracks except audio seem original?
Hi, I learnt enough about converting an audio to midi by keying or typing in from music sheet in a sequencer. But my question is, on the internet many MIDI files are available. Except for voice which is converted to midi, the rest of the tracks that provide harmony etc seem to be a direct conversion from audio CD to midi (that is, it seems to be a direct conversion of non-audio tracks on the CD to midi notes). How do they do that? Reading on the internet, it seems like it is not possible to convert CD tracks to MIDI directly. I also learnt, audio track is manually converted to midi. But wh...

How do people convert many tracks of CD to Midi, all tracks except audio seem original? #2
Hi, I learnt enough about converting an audio to midi by keying or typing in from music sheet in a sequencer. But my question is, on the internet many MIDI files are available. Except for voice which is converted to midi, the rest of the tracks that provide harmony etc seem to be a direct conversion from audio CD to midi (that is, it seems to be a direct conversion of non-audio tracks on the CD to midi notes). How do they do that? Reading on the internet, it seems like it is not possible to convert CD tracks to MIDI directly. I also learnt, audio track is manually converted to midi. But wh...

Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question
This is the most important question of your life. The question is: Do you floss? It is not a question of how well you brush, nor if you use mouthwash, but do you floss? Are you sure you will keep all the teeth you still have? The reason some people don't know for sure if they are maintaining a preventitive oral dentifrice is because they just don't know what those words mean. The good news is that you can know for sure whether you will keep all of your teeth. Dental textbooks describe full-toothed-ness as a beautiful place with no death, sorrow, sickness or pain. Dentitists tell...

Startup macro
Is there a way of getting a macro to run when you make a new part from a template. I have seen the /m switch around but this only runs a macro from startup. Not that I can think of automatically. What is it that you want to do? Can you build it into your template? WT "Dames" <damian.gillespie@couray.com.au> wrote in message news:1106716844.529173.15880@c13g2000cwb.googlegroups.com... > Is there a way of getting a macro to run when you make a new part from > a template. I have seen the /m switch around but this only runs a macro > from startup. > Could a...