Other common macro idioms



  • 1. Sin in Lisp, Lisp is Sin
    Joel Moses of MIT wrote his PhD dissertation on solving freshman calculus problems, a Symbolic Integrator he called SIN. (c. 1967) (It was an improvement, in some sense, of James Slagle's approach to the same problem, a program called Symbolic Automatic Integrator, or SAINT.) SIN (and most of SAINT) were written in Lisp. JM was particularly keen to have his presentations titled "Moses speaks on Sin". The SIN code was incorporated in the Macsyma project, and can be seen in the open-source Maxima program on sourceforge. It was modified in many ways to fit into the Macsyma context. A mostly unmodified version was available for many years in another project, Scratchpad, running on IBM 360 Lisp, at IBM Research. Scratchpad was said to contain the "Original SIN". Scratchpad evolved to Axiom, now also open-source. RJF
  • 2. Unit Test Framework
    Which Common Lisp unit test framework is the most widely used? I want to get some test harnesses up and running, but don't want to find myself using something that most people have rejected.
  • 3. Common-Lisp.net downtime Saturday Jan 14th.
    Common-Lisp.net will be migrated to its new server on Saturday January 14th. I aim at starting the migration around 6PM EST and hopefully I'll be done by midnight; if there are any delays I will post about them where I posted this message. Please plan accordingly, there will be no CVS, web, FTP, SSH or other access during this time period - for testing purposes I may turn these services on and off but please do not try to use them if you discover you can. Also please keep in mind that if the server is not reachable to you after midnight and I haven't posted about extensions your DNS server might not have gotten the updated record. Once complete I will make a post saying everything is ok. Let me know if there are any concerns with this plan. If someone could make this post find it's way to planet.lisp.org that'd be nice. Thanks, Erik.

Other common macro idioms

Postby jmckitrick » Tue, 05 Jun 2007 22:34:33 GMT

The first two are obvious and common: WITH-FOO and DEF-FOO.  What are
some other common idioms for abstractions where it is often
advantageous to express them using macros?

Re: Other common macro idioms

Postby Dan Bensen » Wed, 06 Jun 2007 03:00:37 GMT

FOO* indicates sequential evaluation instead of parallel.
It's normally applied to binding forms, but when I made an
Elisp-style IF macro that puts a progn in the else form,
I called it IF*.


Re: Other common macro idioms

Postby John Thingstad » Wed, 06 Jun 2007 03:56:28 GMT

On Mon, 04 Jun 2007 20:00:37 +0200, Dan Bensen < XXXX@XXXXX.COM >  

Are you aware that ACL already has a IF* macro? They have it available  
(somewhere) on their website.

Using Opera's revolutionary e-mail client:  http://www.**--****.com/ 

Re: Other common macro idioms

Postby Larry Clapp » Wed, 06 Jun 2007 04:23:13 GMT

 http://www.**--****.com/ ~jkf/ifstar.txt

Re: Other common macro idioms

Postby Dan Bensen » Wed, 06 Jun 2007 07:04:07 GMT

Looks like another LOOPish abomination.  :) :)


Re: Other common macro idioms

Postby Barry Margolin » Wed, 06 Jun 2007 09:51:19 GMT

In article < XXXX@XXXXX.COM >,

FOOLET, as in FLET, MACROLET, SYMBOL-MACROLET, etc.  All the built-in 
ones are actually special forms, but I suppose there's a possibility of 
user-defined operators in a similar style.

Barry Margolin,  XXXX@XXXXX.COM 
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Re: Other common macro idioms

Postby Rainer Joswig » Wed, 06 Jun 2007 19:39:22 GMT

In article < XXXX@XXXXX.COM >,

There is also



Similar Threads:

1.Other common macro [naming] idioms

On Mon, 04 Jun 2007 06:34:33 -0700, jmckitrick < XXXX@XXXXX.COM > said:

| The first two are obvious and common: WITH-FOO and DEF-FOO.  What are
| some other common idioms for abstractions where it is often
| advantageous to express them using macros?

  Just looking at standard Common Lisp names:

     * DOFOO and DO-FOO for iteration;
     * FOO-BIND for, well, binding;
     * FOOCASE and FOO-CASE for dispatch;
     (opening CLtL's index of macro names)
     * FOOF for place manipulation

  (by the way, I believe it would be either DEFFOO or DEFINE-FOO, but
  not DEF-FOO).


The truly good code is the obviously correct code.

2.Shortening common idioms: bus assignment and 'prev' generation

Hello all,

In high level programming languages it's possible to shorten common
programming idioms by encapsulating them into functions / modules /
classes. It is similarly possible in simulation-aimed VHDL, but is much
more difficult in synthesis-aimed VHDL.

Here is one:

some_bus(31 downto 27) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(24 downto 20) <= (others => '0');
some_bus(19) <= my_sig_11;
some_bus(18 downto 2) <= (others => '0');
some_bus(1 downto 0) <= another_bus(1 downto 0);

I wish there sould be a way to just assign 'all zeros' to some_bus and
then the signals to relevant bits:

some_bus(31 downto 0) <= (others => '0');
some_bus(26) <= my_sig_3;
some_bus(25) <= my_sig_4;
some_bus(19) <= my_sig_11;
some_bus(1 downto 0) <= another_bus(1 downto 0);

This, unfortunately, doesn't work. Setting some_bus to 'L' also doesn't
work for synthesis (only simulation).

Another common idiom is seeing when a signal changed:

signal my_sig, my_sig_prev: std_logic;
process (clk, reset_n)
  if reset_n = '0' then
    my_sig_prev <= '0';
  elsif rising_edge(clk) then
    my_sig_prev <= my_sig;
  end if;
end process;

And then:

some process:
  if rising_edge(clk) then
    if my_sig_prev /= my_sig then

How can this be shortened, in synthesis ? I find myself writing this or
similar code (checking for a rise, or fall, of my_sig, for instance, by
(my_sig = '0' and my_sig_prev = '1') for fall) too many times !



3.semi-urgent request for common-idioms

Does anyone have a reasonably current version of Brian Mastenbrook's
common-idioms package lying around that they'd be willing to email me
or put on a web server or something?

I have a bunch of software that depends on it, that I'm trying to
install on a new machine, and I can't seem to get it on the internet,
and all my copies are in the office which I can't get to today.



4.SETF and MACRO idiom & archive wisdom...

Douglas Philips < XXXX@XXXXX.COM > writes:

> After numbing myself searching through decades of c.l.l archives, I'm
> not sure if in my stupor I've just passed over what I'm looking for,
> or if the needle I want is on a completely different farm from the
> haystacks I was looking in.
> Is there a way to write a SETF like thing, which does the evaluation
> of place only once, but which returns the _old_ value instead of the
> new? From what I unearthed about SETF (DEFUN (SETF FOO)) (DEF-SETF....
> PUSH isn't a SETy thing because it doesn't return the right thing, etc.
> ... that the answer is 'No'.


5.[Clax86list] using common macros in NASM and C

On 25 Jul 2006 17:21:02 -0700

:Of course, the problem with the ".h"->".inc" translators is that they
:only work with a tiny subset of the stuff that normally appears in an
:.h file.

This may be true for specific translators which you have looked at, but my
experience is that the only thing which is particularly intractable is the
macro definitions.

-- Chuck

6. using common macros in NASM and C

7. Non-Lisp "macro" system closest to Common Lisp's?

8. in macro from ANSI Common Lisp

Return to lisp


Who is online

Users browsing this forum: No registered users and 12 guest