Text or Number
joshua at roughtrade.net
Sun Mar 28 16:19:09 CST 2004
On Mon, Mar 29, 2004 at 06:51:21AM +1000, Sisyphus wrote:
> But normally perl does this "DWIM" stuff for you.
> If I write:
> $x = "1";
> $y = $x * 3;
> then $y always holds the value 3, not 45.
> How does perl's own DWIM handler come to fail for Scott ?
There's no DWIM mechanism for "write this value to a parallel port",
unlike the multiplication operator "*" which supplies an integer
conversion context as necessary.
Which value to output? Ascii '3' or binary 00000011? Bear in mind
that the parallel port can be used as bit-by-bit data acquisition/control
I/O system as well as a character-output device for talking to
This user confusion is precisely the cause of Scott's enquiry.
Scott, this motivates yet another way: make your controlling class
abstract, and then require the user to explictly request a subclass
that implements the actual desired behaviour. Since it's unlikely
that someone will be working in both the character and the acq/control
paradigms, they can request a concrete class that fits their
You can also hide platform-specific implementations behind such a
factory method, giving the illusion of portability.
Joshua Goodall "as modern as tomorrow afternoon"
joshua at roughtrade.net - FW109
More information about the Melbourne-pm