Re: macros
On May 16, 3:19 am, Seamus MacRae <smacrae...@live.ca.nospam> wrote:
Pillsy wrote:
On May 15, 11:10 pm, Seamus MacRae <smacrae...@live.ca.nospam> wrote:
Pillsy wrote:
[...]
This, at least, is a potential problem, but in practice it's never
caused me any difficulty.
*deep sigh*
What?
Every time a serious problem is mentioned, you tend to dismiss it with
little more than a hand-wave.
One thing I've discovered is that the things I think are going to be
problems when I start learning a language (or don't know it at all
yet) end up being pretty different from the things that I actually
learn are problems after working with it for a while.
[...]
What development environments? That curses-based museumstrosity you we=
re
evangelizing half an hour ago? Surely ye jest?
No, Emacs + SLIME has convenient features for locating method
definitions in their source files. Just because the interface looks a
like something out of 1983 doesn't mean it doesn't work well.
I'm sure it does, by 1983 standards.
No, I mean, by 2009 standards. It just looks a little crufty.
[...]
Inheritance relationships recorded where?
In the class definition...? If I want to say that FOO is a subclass of
BAR, I just write
(defclass foo (bar)
;; This space for rent!.
)
Yet earlier someone was saying you'd omit to specify that Complex
inherited from Number.
I might, but if I wanted it to inherit from Number, I could certainly
choose to have it inherit from Number. I'm just not sure that's the
way to go from a design standpoint, though admittedly I haven't
thought about the question a whole lot..
In truth of fact, in Common Lisp, the built-in COMPLEX class actually
does inherit from the built-in NUMBER class.
[...]
You mean, the source code for a dispatch table you posted is
machine-generated, like yacc output?
No, I mean, you never see any of it.
Oh, lovely. Machine-generated code you can't even find and read?
Well, I guess that's one way of describing compilation...? Still, it
strikes me as kind of a perverse one.
It's annoying enough to get bison-generated code to play nice
with version control.
Do you version-control object files and executables? That seems like
strange behavior to me.
[...]
You select the name of the generic function, hit Alt-., and a list
pops up listing all the methods for the generic function and their
classes. Then you click on the one you want, and you're taken to the
definition. It's really, really similar to looking up definitions in
Eclipse.
You assume people are using some particular tool, with a fairly decent
interface, that I ain't never heard of. From all indications, a straw
poll here would show most of the other lispers to be using emacs or
something else equally primitive, though, and there might also be issues
with getting such a tool to work with different dialects of Lisp reliably=
..
The tool I was describing in that paragraph is called... Emacs.
[...]
Let me guess, "there's no problem", by
which is meant "it is physically possible, though you'll need a few
tablets of Excedrin afterward and might want to save up a few sick day=
s
first".
No, I mean, "there's no problem", by which is meant that I can't even
figure out what problem you might be referring to.
Fully-qualifying the fuckin' names! What the hell else could I be
referring to? :P
Oh, no, most of the time, you can just use both packages (i.e.,
namespaces) in the package you're working in without having to fully
qualify anything. If there are clashes, you can specify which package
you want to use for a given unqualified name, and qualify the other
one.
[...]
Such a pain, when Java lets you just go
public class MyWhatsit {
@Override
public String toString () {
return "I'm a MyWhatsit!";
}
}
sticking this in your own namespace and not monkeying with any other
code anywhere (either manually, or by running some sort of
code-generator), yet if a MyWhatsit is subsequently passed to e.g.
String.valueOf(Object), out pops "I'm a MyWhatsit!".
I'm really not seeing much difference between that and
(defclass my-whatsit () ())
(defmethod print-object ((object my-whatsit) stream)
(print-unreadable-object (obj stream)
(format stream "I'm a whatsit!")))
That's all you have to do. No monkeying with any other code anywhere
else. No code generation.
Let me guess: no MANUAL code generation. Something in the toolchain does
it for you.
Well, like I said, in Lisp we have this thing called a compiler.
Perhaps you've heard of them...?
That's not quite the same thing. And there's no namespace-related stuff
in your code. OK, there was none in mine, either, but you can just slap
a "package foo;" at the top of it.
And I could just slap
(defpackage #:foo (:use #:cl))
at the top of mine.
Whereas yours requires you to
defmethod the pre-existing, in some widely used namespace, print-object
method, with who knows what potential risks if you screw it up.
I know what potential risks. The potential risks are that something
could go wrong when you try to print an instance of MY-WHATSIT.
[...]
In Common Lisp, you'd just write the four method definitions; you
wouldn't even have to mention the "implements Number" part.
That was you! It's your own previous post you contradicted up there by
putting explicit subtyping declarations into some of your example code.
Yes, it was. Whether you decide to inherit or not is a matter of
choice.
[...]
Eh, wait a minute, you'd write the four method definitions and then ru=
n
that code-generator thingy to generate the new versions of the dispatc=
h
tables.
No, you write the four method definitions and then compile them. All
the machinery for doing the dispatch is handled by the Lisp
implementation transparently.
Like a C++ vtable, then, except that you (or a bug in your code) can
screw with the vtables for objects from the standard library, the
vtables for MY objects, ...
Well, no. I could muck with the dispatch tables for the generic
functions in the standard library, but unless we're using a bizarrely
crappy and bug-ridded implementation, that won't hurt you any. The
methods you've defined on YOUR-WHATSIT will be invoked on YOUR-
WHATSIT, the methods I've defined on MY-WHATSIT will be invoked on MY-
WHATSIT, and there won't be any interference between the too.
Cheers,
Pillsy