in reply to Re: OO: Leaving a constructor midway?
in thread OO: Leaving a constructor midway?
The magicking action in Perl may be bless. But, OOD/OOP are language-independent concepts. The fact that Perl has certain quirks in how it implements OO (as opposed to the C++ or Java quirks) should be irrelevant to a discussion of OO technique.
The "popular way" of using a subroutine called as a class method that returns a blessed reference also happens to be a rather decent implementation of an OO design for constructing an object. Your statement about "on the language level" is irrelevant to the discussion. On the language level, C++ reuses a ton of C features that are not OO. So does Perl. So what?!?
OP is calling some class method sub (presumably named new) as a constructor. His program calls it, probably with some set of values, and gets back something that looks, talks, and walks like an object. Sounds like a constructor to me? The fact that, under the hood, it calls bless is completely irrelevant to the client code. In fact, a number of programmers use OO Perl without ever knowing about bless.
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Leaving a constructor midway?
by Abigail-II (Bishop) on Oct 22, 2003 at 14:23 UTC | |
by dragonchild (Archbishop) on Oct 22, 2003 at 14:44 UTC | |
by Abigail-II (Bishop) on Oct 22, 2003 at 15:38 UTC | |
by oylee (Pilgrim) on Oct 22, 2003 at 16:32 UTC |