Nick --
I've been thinking of it like this:
class int isa intlike; # and isa value or whatever
class Int isa intlike; # and isa Object or whatever
class num isa numlike; # and isa value or whatever
class Num isa numlike; # and isa Object or whatever
...
class Scalar
class Scalar isa intlike, numlike, ...; # and isa Object or whatever
Qoting A6: Perl makes a distinction between the type of the variable,
and the type of the value
If we view Scalar as the type of a variable, not value, then we could
cease to need all this cleverness with inheritance. People
]
cc:
Subject:Re: A6: Complex Parameter Types
There seems to be some confusion about which way up the world is.
On Tue, Mar 11, 2003 at 01:25:41PM +1100, Damian Conway wrote:
Which in turn is because:
not Scalar.isa(int)
On Thu, Mar 13, 2003 at 11:55:06AM
There seems to be some confusion about which way up the world is.
On Tue, Mar 11, 2003 at 01:25:41PM +1100, Damian Conway wrote:
Which in turn is because:
not Scalar.isa(int)
On Thu, Mar 13, 2003 at 11:55:06AM -0800, Larry Wall wrote:
On Thu, Mar 13, 2003 at 11:31:30AM -0800, Austin
I'm not sure if it helps people understand why I'm confused by explaining
my background, but I've done exactly zero computer science, and have come
to whatever (mis)understanding of OO I have by using C++ (and then perl).
I've never used Java, but I'm aware that it has a concept of interfaces
Oh goody, two with one blow:
--- Damian Conway [EMAIL PROTECTED] wrote:
Larry wrote:
: multi foo (@a is Array of int) {...}
:
: my int @a = baz(); # is Array of int
: my @b = baz(); # is Array of Scalar
:
: foo(@a);# @a is typed correctly, so OK
:
Austin Hastings wrote:
You're treading dangerously close to the SM line there...
Sure. That's exactly what types are for.
Does it make sense to say Cuse strict params; for this stuff?
I'd much rather that simply using typed params invoked type stricture.
Damian
Larry wrote:
: multi foo (@a is Array of int) {...}
:
: my int @a = baz(); # is Array of int
: my @b = baz(); # is Array of Scalar
:
: foo(@a);# @a is typed correctly, so OK
: foo(@b);# @b is not explicitly typed as Cint; OK or FAIL?
snip
I dunno. I can argue that
On Tue, Mar 11, 2003 at 01:25:41PM +1100, Damian Conway wrote:
: 3) The edge point between explicitly typed and explicitly non-typed
: variables: If you pass an untyped array (or list?) to an explicitly
: typed array parameter, is the untyped array considered a unique case,
: or will it fail?
Larry Wall wrote:
I dunno. I can argue that it should coerce that. It'll certainly be
able to coerce a random scalar to int for you, so it's not a big stretch
to coerce conformant arrays of them. On the other hand, it's likely
to be expensive in some cases, which isn't so much of an issue for
Larry wrote:
: multi foo (@a is Array of int) {...}
:
: my int @a = baz(); # is Array of int
: my @b = baz(); # is Array of Scalar
:
: foo(@a);# @a is typed correctly, so OK
: foo(@b);# @b is not explicitly typed as Cint; OK or FAIL?
:
: Fails.
:
: Because:
:
:
In A6, it is confirmed that you can have complex types such as:
my %pet is Hash of Array of Array of Hash of Array of Cat;
It is also confirmed that you can indeed use such types in sub
signatures, e.g.:
sub foo (@a is Array of int) {...}
Confirmations/Questions:
1) Complex types for sub
Michael Lazzaro asked:
1) Complex types for sub parameters: The above would imply that a sub
can tell the difference between an CArray of int vs an CArray of
str, thank goodness. That also implies that you can use arbitrarily
complex types, and still get the same type checking:
sub foo (
13 matches
Mail list logo