At least these languages (that I know of) have macros:
http://boo.codehaus.org
http://nemerle.org
http://www.perl6.orgLisps might not be the only languages with macros, but they're the only ones with elegant and easy to use macro systems.
You could argue of course this is a moot point, since even Lispers only write macros infrequently. So who cares if it's hard to write one on the rare occasion you need to?
>> a: [ 300 3 ]
>> insert a 'add
>> probe a
[ add 1 2 ]
>> print first a
add
>> do first a 100 1
== 101
>> do a
== 303
>> f: func [] a
>> f
== 3
>> change second :f 'subtract
>> f
== 297
all code is data (blocks of words and values).From * Io * example below I would say it's a little different. It's more like it has a runtime api to change/generate it's runtime. I think SmallTalk has something similar to this.
* Factor * has compile time macros. At runtime it has quotations, which are blocks of code (separate from it's other data strucures I think, but don't shoot me if I'm wrong) that can be modified and executed by your code with few specific words like curry and compose. This means you have a little less freedom than in rebol where block of code is in no way different than a block of data. What is awesome about factor is that it also compiles quotations at runtime.
Otherwise Factor is very very cool, and I envy some runtime features of Io a lot.
And Python has as little to do with lisp as Visual Basic. Python is the world's best dynamic Imperative lang IMHO :)
In Io, all code is data. Below is an example of changing a functions behaviour (from addition to subtraction):
Io> plus := block (a, b, a + b)
==> method(a, b,
a + b
)
Io> plus call (1, 2)
==> 3
Io> plus message next setName ("-")
==> -(b)
Io> plus
==> method(a, b,
a - b
)
Io> plus call (1, 2)
==> -1
ref: Io Has A Very Clean Mirror (WayBackMachine copy) - http://web.archive.org/web/20080212010904/http://hackety.org...Its homoiconic but its not a Lisp. And it doesn't have macros yet its code is fully inspectable/modifiable at runtime in an very easy & elegant way.
For eg. if you wanted to have a line like this:
list(1, 2, 3) each foo bar
which needs to be transformed into below at runtime: list(1, 2, 3) foreach(foo bar)
Then this can be done like so: List each := method(
m := call message
m setName("foreach") setArguments(list(m attached)) setAttached(nil)
self doMessage(m)
)
ref: http://www.iolanguage.com/blog/blog.cgi?do=item&id=86This simply isn't true. In fact it's so far from the truth it hurts my brain. Well written Lisp applications are in large part (and sometimes mostly) macros. PG once mentioned that the ITA guys said over half of their codebase is (was?) macros.
For my own code, it consists of maybe 10% macros. I would say the same is true for PG's code (for the hacker news app- The arc core libraries have more macros but are a special case.)
Unless, of course, if you mean _calling_ macros- I would agree that Lisp code often has 50% of its calls be macro calls instead of function calls.
In Perl 6, you extend the active grammar within a delimited scope.