in reply to Re^5: Benefits of everything is an object? Or new sigils?
in thread Benefits of everything is an object? Or new sigils?
That wasn't my point... I was talking about design decissions an cleaner syntax.
If it's unclear if you will be going to bless or tie a _specific_ primitive array into a class and you wanna stay flexible you will have to use references right from the beginning:
And this will force you into to sigil accrobatics like writing things like push @$ref,"elem"
In this case - i.e. only when dealing with primitives - it's an option to use $ref->push("elem") right from the beginning to have a cleaner syntax. (The resulting caveates like speed punishment are listed in the OP.)
But IF you decide later to extend this class you can _bless_ $ref into a new class with list_active -method, without changing the interface you used and without poluting other arrays.
Anyway my prefered - "utopic" - syntactic solution is to have an extra special sigil for arr_refs, such that you can still write push €ref,"elem" (or even €ref->push("elem") according to your taste) without sigil accrobatics.
This (and other syntactic simplications) would make Perl5 much easier to use and to learn without breaking compability to older sigils. (And would build a migration bridge to Perl6) Perl forces you anyway to use refs in bigger programs, IMHO there is no big point of @ and % if you can't use them to distinguish the underlying structures.
BTW: > @employees->list_active
shouldn't be possible ... neither with autobox nor blessing, you will have to write something like
\@employees->list_active
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Benefits of everything is an object? Or new sigils?
by JavaFan (Canon) on Mar 03, 2010 at 16:34 UTC | |
by LanX (Saint) on Mar 03, 2010 at 16:42 UTC |