Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: my Dog $spot;

by TedYoung (Deacon)
on Jun 07, 2006 at 16:24 UTC ( [id://554083]=note: print w/replies, xml ) Need Help??


in reply to Re^2: my Dog $spot;
in thread my Dog $spot;

Let's not forget that while native phash syntax is going/gone, phashes still exist in the form of use fields. IIRC, you still need to use the my Dog $spot syntax if you want compile-time checking of field based classes.

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

Replies are listed 'Best First'.
Re^4: my Dog $spot;
by TimToady (Parson) on Jun 07, 2006 at 18:01 UTC

      My Tie::Constrained follow-on is meant to do exactly what the Value Types spec describes: to restrict the types which can be assigned to a variable. I don't imagine Perl 6's internals for my Dog $spot; will be much like Perl 5's attribute- and phash-centered code, but the effect would be the same. In fact, it would be trivial to modify T::C to get enforcement of a seperate returns property.

      The restrictions T::C can impose are quite flexible. By constructing what the pod of the current version calls &validator from &UNIVERSAL::isa or &UNIVERSAL::can, we can leash poor $spot either by type or by capability. Constraints on allowable values are just as easy to set up, and detainting before assignment is available as a bonus.

      I'm the first to admit that Perl 6 doesn't loom large for me, but I have been aware of it.

      Added: I've posted example code for a strong typing/value type Dog at Re: my Dog $spot;. It's as experimental as ever.

      After Compline,
      Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://554083]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found