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

Re^4: Quantum Weirdness and the Increment Operator

by japhy (Canon)
on Jun 24, 2004 at 13:37 UTC ( #369355=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Quantum Weirdness and the Increment Operator
in thread Quantum Weirdness and the Increment Operator

First of all, ihb is not someone who wouldn't read the C docs if the Perl docs told him to. He is arguing on behalf of beginners, and those without a C background, etc.

Second, your analogy has a fallacy: algebra is a pre-req for calculus, but C is not a pre-req for Perl. A person going into Perl first of all languages is not expected to know C (or sed, or awk, or sh!). Therefore, depending on just what behavior it is they have to refer to C for, they might not understand what it is they're reading, because it'd be in a C context, not a Perl context. Besides, how much of Perl behaves like some language from which it is derived? Why don't we bundle the docs from those other languages with Perl, so Perl's docs can merely cross-reference theirs?

One problem I see is that while Perl is written in C, Perl does things differently than C. For one, Perl handles this pre-inc and post-inc thing differently. The documentation says the behavior is undefined, but it had better NOT say the behavior is undefined, "just like in C", because it is obviously not. I think Perl's docs need updating, in this case. I think the behavior is definable, we just haven't written it down to define it.

Instead of yelling at the original poster for venturing into the forbidden zone... I don't know. Something. Just don't chastise him for experimenting with the language and reporting his findings. He's learning. Let him learn.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;


Comment on Re^4: Quantum Weirdness and the Increment Operator
Re: Quantum Weirdness and the Increment Operator
by Abigail-II (Bishop) on Jun 24, 2004 at 13:49 UTC
    Just don't chastise him for experimenting with the language and reporting his findings. He's learning. Let him learn.
    Oh, goodie. Now that's helpful! Anyone who's experimenting with the language, we just let them go, and admire them from a distance, keeping silent.

    And then we wonder why people stop programming in Perl because their production code failed in mysterious ways. They walked into a swamp, and we let them, cause that will "teach them".

    Now please excuse me, I've some "dangerous curve" signs to remove.

    Abigail

      You are misinterpreting me. I did not say to "let them go", "keeping silent". I said not to chastise the orignal poster for saying "this code confused me, so I tried to find out why it works the way it does, and this is what I found out".

      Certainly, tell him not to use that kind of construct in his production code, and tell him that the documentation does not provide a defined behavior for it, but don't be angry or impatient with him.

      And you've blended "learning" with "doing in practice". Just because I learn something (like how crazy this ++X and X++ business is) does not mean I'm going to employ it. Some "swamps" need to be investigated for signs of life, but that doesn't mean the scientist needs to live in the swamp.

      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
        What the fuck do you want from me? I explain what's wrong, including quotes from the documentation, and still you're not satisfied. Should I've called a couple of social workers to bring the news to him easily?

        Abigail

Re^5: Quantum Weirdness and the Increment Operator
by itub (Priest) on Jun 24, 2004 at 15:42 UTC
    I think the behavior is definable, we just haven't written it down to define it.

    I think you don't understand the idea behind the concept of "undefined behavior" in language specifications. It doesn't mean that the language will use a random number generator to give you an unpredictable result every time. In most cases, you'll find that the behavior is perfectly reproducible, and you could think of documenting it. Don't do it! Undefined behavior means that compiler writers has the freedom to choose whatever behavior they want, and the users of the language SHOULD NOT rely on the way the behavior is "defined", because the compiler writer has the freedom to change it in the next version.

    It's just like saying: cool, this module has this interesting undocumented variable! Let's use it! If you use it, it's under your own risk. The documentation is like a contract. And please don't send a documentation patch to the author before making sure that it's not undocumented for a reason.

      But I don't think this behavior should be changed, unless you were to change how Perl uses its variables entirely! It works naturally (that is, following a set of natural rules) due to how Perl itself works (that is, due to Perl's set of rules).
      _____________________________________________________
      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

        This behaviour has been under discussion as something just may well change. There was a discussion between Juerd and hv once where Juerd said something something the current way being the only sane way, really, and then hv countered with something else reasonable (this is all perl6 mind you) and noted that this behaviour is undefined for a reason.

        The observed behaviour is an artifact of the implementation - different implementations are allowed to have different behaviours.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-03 06:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls