Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Comment on

sub simple_properties { my %properties = %{ shift() }; my ($emissive, $diffuse, $shininess, $specular, $transp); foreach my $property (keys %properties) { if ($property eq "emissive") { $emissive = "emissiveColor @{$properties{ $property }} "; } elsif ($property eq "diffuse") { $diffuse = "diffuseColor @{$properties{ $property }} "; } elsif ($property eq "shininess") { $shininess = "shininess @{$properties{ $property }} "; } elsif ($property eq "specular") { $specular = "specularColor @{$properties{ $property }} "; } elsif ($property eq "transparency") { $transp = "transparency @{$properties{ $property }} "; } } return <<"EOR"; appearance Appearance { material Material { $emissive $diffuse $shininess $specular $transp } } EOR }
Some of you may recognize my VRML endeavours from my home node. The above code does in fact work. And it's even pretty clear. However, every once in a while a great saint will come along and give me some suggestions that remarkably clarify what I am doing. So here are some things i'd like to clear up:
  • I don't like the creation of %properties but I dont see a real good way to do it other than how its being done.
  • I also dislike the use of separate strings for interpolation of the arrayrefs. However, I see them as being necessary for understanding the return value. Of course, there is more than one way to do it. I'm hoping somebody can come up with a way that is both simple and clean.
Here's some more code.
sub directional_light { my ($amb_intensity, $color_r, $direction_r, $intensity, $on) = (@_); my @color = @{ $color_r }; my @direction = @{ $direction_r }; $on = etf( $on ); return <<"EOR"; DirectionalLight { ambientIntensity $amb_intensity color @color direction @direction intensity $intensity on $on } EOR }
This part kind of irritates me as well. The heredoc here is much clearer. What bothers me though is the creation of the arrays using sort of 'placeholder' values (which japhy understandably hates). The only way I can see to work around this is :
my (@array, @other_array) = (@{$_[0]}, @{$_[1]});
which I find rather ugly and not particularly clear.

Anyhow, I'm particularly exhausted after a long day of hacking at the forthcoming (hopefully) I hope my fellow monks can shed some light on this and save me a little time in refactoring.

yours truly,
el deppo

Laziness, Impatience, Hubris, and Generosity.

In reply to Optimizing variable passing (code, peer review) by deprecated

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-12-27 10:12 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (176 votes), past polls