G
Gareth McCaughan
Kenny said:Gareth McCaughan wrote: ....
Naw, I was just being a d*ckhead. That is what /I/ do at 1:30am when I
get back from the pub.
Fair enough.
Kenny said:Gareth McCaughan wrote: ....
Naw, I was just being a d*ckhead. That is what /I/ do at 1:30am when I
get back from the pub.
C++ method call: foo.munge(bar);
Equivalent Lisp call: (munge foo bar)
The C++ function specializes on the first argument, that is to say "foo".
The language doesn't support multi-methods, so if you want to specialize on
bar as well, you'll have to do it by hande.
It sounds like you're claiming that encapsulation is a integral part of
"object orientation". This comes up a lot in discussions of CLOS.
No, I am not manipulating strings or data, I am manipulating code.
Although C macros work on strings, Lisp macros do not, despite the
fact that the Lisp source code does reside in a file. This is because
the Lisp reader parses the expressions for me and hands my macro a
data structure. This particular example is rather simple, but there
are plenty of other uses of macros in which a code 'tree' is
traversed, examined and transformed. This is far more powerful than
simple string substitution as C has.
However, there are those who feel that defining new syntax is too
powerful a feature for a language, they should stay clear of this sort
of thing.
newsmailcomp5 said:You are describing a program-generating program as self-modifying.
Using your discription every compiler which can execute its generated
code would be self-modifying (like a Common Lisp compiler). I think
many people (including myself) will disagree with you, e.g. see:
http://en.wikipedia.org/wiki/Self_modifying_code
I have only heard the term self-modifying in the context where the
program will modify the some of its following instructions. The
purpose is to implement adaptive algorithms and to save program
memory. Self modifying code has been known to cause problems with the
CPU instruction cache. However, self-modifying programs are not so
common since memory is cheap and almost all CPU's have instruction
caches where one would like to keep a high hit-ration as possible.
Oh really? So you shouldn't use imperative code in an OO application?
Interesting.
Yes, we're not true cultists, sorry. We don't follow the One True Way of
typopace (type/scope/namespace) object orientation in every line of our
code. We'd rather write each section of code in a way that allows that
code to make as much sense and be as maintainable as possible. We're
horrible people.
Gerry Quinn said:That's part of it. But my main point is that "object orientation" means
more than "allowing objects". You have to be oriented towards classes.
If you are oriented towards functions, or macros, you are not object-
oriented.
Gerry said:But my main point is that "object orientation" means
more than "allowing objects". You have to be oriented towards classes.
If you are oriented towards functions, or macros, you are not object-
oriented.
Gerry Quinn said:And their are those who are more interested in 'clever' programming than
in producing useful software - they will doubtless love it.
That's part of it. But my main point is that "object orientation" means
more than "allowing objects". You have to be oriented towards classes.
You can be oriented to objects, or oriented to something other than
objects. Your choice. What you can't do is say "here's the OO language
feature, we're not going to use it much but just because it's there our
programs must be object-oriented."
My habit is to start a class definition with:
class MyClass
{
public:
// member data
protected:
// member data
public:
// member functions
protected:
// member functions
};
(only without the comments). Ideally the first category should be
empty, and typically the fourth is biggest. Often I move stuff around
during development.
One minor dilemma I often encounter is whether to use accessor
functions to get at protected data. Ideally, I suspect, a class
should have its own internal accessors, but that is too much
typing, so it remains conceptual! I do sometimes implement it in a
small way, i.e. with a public const accessor, and a protected
non-const accessor/mutator.
Most likely you wouldn't, but if you wanted it, that's how it would
look like. Maybe I should have just written f(a, b) / a.f(b) /
T::f(a, b), but I kind of wanted to go with the "rabbit jump" thing.
Gerry Quinn wrote:
There's an advantage of Lisp right there, then. It's very, very easy to
define accessor methods (or separate reader and writer methods, if that
fits better), and if you later change the contents of the slot (or remove
it), you can just remove the accessor declaration and define your own to
fit the new slot.
It's what I suspect you wanted to do, and the compiler is smart enough that
accessor calls don't neccessarily involve function calls, especially if you
use type declarations.
But any good programmer is certainly held back by lesser languages. I
found Lisp because, well, there is another category in the survey, for
those who went on an active search for a better way before they even
knew there was a better way, simply because they sensed that they were
being held back by their languages.
Nobody's said that. They've said the /language/ is OO. C++ doesn't have
much of a better claim beyond the fact the type system needed explicit
extension to add OO to it.
The other thing is that people actually DO program C++ in an OO fashion.
Not always, but often enough. Correct me if I'm wrong, but Lisp-ers
give a distinct impression of preferring generic programming.
Gerry Quinn said:And if Lisp programmers were demonstrably more productive and effective,
I'd take such claims seriously.
IM(limited)E, lispers code however they feel is best for the task.
Personally (as a non-lisper but with a related mindset) I often end up
with designs that look like OO designs in the large, I just don't find
traditional OO tools to be a useful means of doing programming in the
small (including the higher-level bits of code). Actually, I'll go a step
further - I don't find traditional OO tools to be a useful means of
analysing much (of my) programming in the small. I find they tend to offer
extensibility in all the wrong places, for example.
One thing I /do/ make a lot of use of is (sub)systems communicating in a
specified language. In fact, a current project has a setup that looks
suspiciously like threads-as-objects for pretty much that reason. Many of
my preferred constructs end up looking pretty close to the duals of OO
constructs, for that matter. Which makes a lot of sense if the traditional
OO constructs seem to be getting everything backwards.
Gerry Quinn said:And if Lisp programmers were demonstrably more productive and effective,
I'd take such claims seriously.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.