Hi,
I am still a Lisp beginner but I played quite a lot with macros. It
is a very powerful tool but I also discovered that, as a
side-effect, it can make your code look more cryptic.
That leads us to the following question : what is the most
obscure/obfuscated piece of macro you, dear Lisp hackers, have ever
seen ?
Thanks in advance
Zakath
Zakath wrote:
> Hi,
>
> I am still a Lisp beginner but I played quite a lot with macros. It
> is a very powerful tool but I also discovered that, as a
> side-effect, it can make your code look more cryptic.
>
> That leads us to the following question : what is the most
> obscure/obfuscated piece of macro you, dear Lisp hackers, have ever
> seen ?
Why don't you start the ball rolling with your discovery? I mean, since
you already have an example or examples in hand, share that.
i do not get confused by language constructs, I get confused by the
mechanisms I create sometimes because I program by the seat of my pants.
But it won't be macros or classes or functions or specials that
confuse me, it will be the engines I build from them. ie, something
always at least one level higher.
which is why I am asking for your known example, because I cannot
imagine a macro per se confusing me.
kenny
--
Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film
"Doctor, I wrestled with reality for forty years, and I am happy to
state that I finally won out over it." -- Elwood P. Dowd
Kenny Tilton <·······@nyc.rr.com> wrote:
> which is why I am asking for your known example, because I cannot
> imagine a macro per se confusing me.
Something like this would confuse *me*:
(defmacro setx (value place) `(setf ,place ,val))
i.e. a macro that partly follows (name), partly contradicts (ordering)
expectaction/convention. It's not that it would necessarily be a bad
idea; this macro could make perfect sense within its context. It's
just that it would be confusing unless one is prepared for it.
(Again, I *am* easily confused...)
Peter Lewerin wrote:
> Kenny Tilton <·······@nyc.rr.com> wrote:
>
>
>>which is why I am asking for your known example, because I cannot
>>imagine a macro per se confusing me.
>
>
> Something like this would confuse *me*:
>
> (defmacro setx (value place) `(setf ,place ,val))
>
> i.e. a macro that partly follows (name), partly contradicts (ordering)
> expectaction/convention.
OK, but bad names are not specific to macros. I once worked on a tricky
little app whose four key controlling variables were aa, bb, cc, and
(wait for it) dd. I had the pleasure of discussing this with the author,
too. :)
kenny
--
Cells? Cello? Cells-Gtk?: http://www.common-lisp.net/project/cells/
Why Lisp? http://lisp.tech.coop/RtL%20Highlight%20Film
"Doctor, I wrestled with reality for forty years, and I am happy to
state that I finally won out over it." -- Elwood P. Dowd
Kenny Tilton <·······@nyc.rr.com> wrote
> OK, but bad names are not specific to macros.
No, but a function or variable can't combine bad (or merely
unfortunate) naming with unexpected redefinitions of the local syntax.
What I'm trying to get at is that code doesn't have to be cryptic or
obfuscated to be confusing. I now realize that the OP was indeed
asking for examples of "cryptic or obfuscated", so I'll shut up now.
Zakath wrote:
> Hi,
>
> I am still a Lisp beginner but I played quite a lot with macros. It
> is a very powerful tool but I also discovered that, as a
> side-effect, it can make your code look more cryptic.
Macros make your code look exactly how you want it. If the code is
unnecessarily cryptic, it's because you designed the macro that way, or
abused a given macro beyond its intended use.
We encode programs by cramming their meaning into high-level
abstractions (that's why it's called ``code''). Because programs are
written in code, they are all cryptic in the sense that you can't
understand the code if you don't know the abstractions.
Abstractions create a barrier against understanding that you have to
cross once. You learn the abstraction, and if you learn it well then
you properly understand it whenever you encounter it in the program
code. If the programmer hadn't developed and used the abstraction,
then he would have created a permanent barrier against understanding,
recurring in every part of the program where the abstraction ought to
have been used.
When I say abstractions, that isn't confined to macro operators, but
covers functions too, as well as data abstraction and everything else.
Zakath <···········@laposte.net> wrote:
> I am still a Lisp beginner but I played quite a lot with macros. It
> is a very powerful tool but I also discovered that, as a
> side-effect, it can make your code look more cryptic.
then you didn't define the right macros. Macros should lead to better
readable programs. Perhaps the macro itself can be complicated, but the
code which uses the macro should be better to read than without the macro.
> That leads us to the following question : what is the most
> obscure/obfuscated piece of macro you, dear Lisp hackers, have ever
> seen ?
Macros can be complicated, but it's all Lisp with the same easy syntax.
Searching at Google for "defmacro obfuscated" gives 29 results, compared to
5120 results for "c++ template obfuscated" :-)
--
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de