Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: Runtime introspection: What good is it?

by stvn (Monsignor)
on Jul 06, 2008 at 18:44 UTC ( [id://695857]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Runtime introspection: What good is it?
in thread Runtime introspection: What good is it?

I said, I consider it a special case, not that it is. And this isn't about winning an argument, it's about drawing them out prior to considering them and then reaching my own conclusions.

But you simply said "I consider them a special case" and provided no reasonable argument as to why they should be considered as such. If you have an argument I will gladly listen to it, but simply saying "i consider it to be ..." is not sufficient.

See Re^2: Runtime introspection: What good is it?

Yes, see Re^3: Runtime introspection: What good is it?.

-stvn
  • Comment on Re^5: Runtime introspection: What good is it?

Replies are listed 'Best First'.
Re^6: Runtime introspection: What good is it?
by BrowserUk (Patriarch) on Jul 06, 2008 at 19:05 UTC
      Indeed, I would say that run-time dispatching upon the base type (HASH/ARRAY/SCALAR/CODE etc.) of a reference is likewise, something of a 'special case'.

      That is all you said, am I missing something, you go on to discuss the types of runtime introspection you are more interested in, but never go back to justify why this is a special case. Your prior reasoning that ...

      the fact that it is under compiler/interpreter control, rather than programmer control, makes it a somewhat different animal to the normal.

      ... has several holes in it. First, all code is under the control of the compiler/interpreter, so what makes this a special case. When I say:

      my $x = "Foo" . 10;
      A conversion happens to the IV that stores the 10 so that it can be concatenated to the string "Foo". You could argue that this conversion is implicit, but really any programmer with even a cursory knowledge of Perl would know that the 10 will get converted to a string before it is concatenated, so is it really that implicit? Or is it really pretty explicit? I would argue for the later. A stricter language, I will use OCaml so that you can compile the example if you like, would look like this:
      let x = "Foo" ^ int_as_string(10)
      The 10 must first be converted from an integer into a string manually by the programmer, but is this really all that different from the Perl version?

      Now, here I would agree with you, Perl could use does use compile time decision making to determine that the literal 10 and the literal "Foo" are going to be concatenated and actually replace this with the string "Foo10" and thereby eliminate the need for any runtime introspection/conversion of the IV. However, this type of thing only works if you only have literal values. Even if we do introduce variables, we still need to know (at compile-time) the type of our variables if we are to have the compiler generate code that doesn't require runtime introspection.

      UPDATE
      Thanks to ikegami for pointing out that Perl actually does do the compile time decision making when presented with two literals. B::Concise never lies :)

      % perl -MO=Concise -e 'my $x = "Foo" . 10;' 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v ->3 5 <2> sassign vKS/2 ->6 3 <$> const[PV "Foo10"] s ->4 4 <0> padsv[$x:1,2] sRM*/LVINTRO ->5 -e syntax OK

      -stvn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found