Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

(dws)Re: Optimizing variable passing (code, peer review)

by dws (Chancellor)
on May 11, 2001 at 10:29 UTC ( #79650=note: print w/replies, xml ) Need Help??

in reply to Optimizing variable passing (code, peer review)

Have you considered making properties first-class Objects? This could lead to greatly simplified code. Consider
package EmmisiveColor; sub new { my $pkg = shift; return bless [ @_ ], $pkg; } sub as_string { my $self = shift; "emmisiveColor @$self" }
And so on for the other properties. Properties become easier to enumerate. You can do away with the switch entirely. Assuming you're doing so within the context of an object that holds properties, your snippet reduces to something like:
sub simple_properties { my $self = shift; my @propstrings = map { $_->as_string() } $self->properties(); return "appearance Appearance {\n" . " material Material {\n" . " ", join("\n ", @propstrings), "\n" . " }\n" . "}\n"; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://79650]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2017-05-23 01:54 GMT
Find Nodes?
    Voting Booth?