• Buddy (unregistered) in reply to Jay
    Jay:
    Dennis:
    When the 'is equals' operator ceases to be commutative, then you're in for a world of hurt.

    Equality can't be commutative - commutativity means that the order of terms used in an operator don't matter e.g. ab=ba. Note that a notion of equality is required to test commutativity.

    Equality is symmetric - "a=b" implies "b=a"

    Just to be joyously contrarian:

    Yes, in ALGEBRA, it is meaningless to ask whether equality is commutative because equality is a relation and not an operation. It can be, for example, reflexive, symmetric, and transitive, but not commutative.

    But in many computer languages, including Java and C++, equality is an operation. "a==b" is an operation on two values that returns a value, true or false. It is perfectly valid to include it as a part of a larger expression, like in C I could write "((a==b)+1&7)", and that could be evaluated to give some result.

    Therefore, in such languages, to say that equality is commutative is a completely valid and meaningful statement. Just as "2+3" gives the same result as "3+2", namely "5", and thus addition can be said to be commutative, so "2==3" gives the same result as "3==2", namely "false", and thus equality can be said to be commutative.

    It's rather intellectually amusing, if you're of that frame of mind. Perhaps compiler writers have introduced a fundamental advance to mathematics without really thinking about it: unifying the concepts of "commutivity" and "symmetry".

    ...

    Thank you. That's what I meant by "is equal" operator, but didn't want to get into a discussion of abstract algebra. You explained it much better than I could.

  • tycho (unregistered) in reply to Trerro

    Just to be clear, Perl arrays don't allow access through non-integer indexes. Perl hashes do, though. In PHP, they noticed that arrays are special cases of hashes, and so just collapsed them into a single data structure. It has it's appeal, I suppose. I just wouldn't want to program without a distinction between a hash and an array.

  • (cs) in reply to tycho
    tycho:
    Just to be clear, Perl arrays don't allow access through non-integer indexes. Perl hashes do, though. In PHP, they noticed that arrays are special cases of hashes, and so just collapsed them into a single data structure. It has it's appeal, I suppose. I just wouldn't want to program without a distinction between a hash and an array.

    Another way of thinking of this is that PHP added "array-like" capabilities to the Awk associative-array structure, as long as the data follows certain rules. Either way you look at it though, it's still broken. Table-ish things and Order-ish things really are fundamentally different.

  • Brian (unregistered)

    At least the guy followed a consistent pattern.

  • hobbes (unregistered) in reply to tycho
    tycho:
    Just to be clear, Perl arrays don't allow access through non-integer indexes. Perl hashes do, though. In PHP, they noticed that arrays are special cases of hashes, and so just collapsed them into a single data structure. It has it's appeal, I suppose. I just wouldn't want to program without a distinction between a hash and an array.
    I've had a similar discussion ( argument ) with a coworker a number of times. My point of view is this; As a language, it's job is to enable me to do what I need to do and get out of the way the rest of the time.

    In PHP's case, it collapses down a number of different variable types ( python's dictionaries and lists ) in to a single variable type. This works for me, as now I don't have to worry about what type of variable I should use here, or as the algorithm updates if I need to change it. That's the job of the compiler/language/computer to keep track of that data, mine is simply to implement the algorithm.

    I mean really, why should I care if I am implementing a list or a dictionary? How is me worrying about that beneficial to the implementation of the algorithm?

  • M2tM (unregistered) in reply to Kazan

    PHP is a bad language. It is a poorly planned cobbling of various elements over a long period of time.

    I work with the language every work day and there are various real-world problems with the language, just do a google search for a few examples. This is not to say that you need to write poor code because the language itself is poor, it is also not to say that PHP hasn't been getting better over time. I write very clean and readable code with the language.

    But to suggest PHP itself doesn't deserve some amount of poking fun at is silly. I mean, honestly, whenever you've got something like magic quotes (or hell, any language feature that needs to be called "magic") you know you're getting into some scary territory. Yes it is depreciated, but you still have to account for it when developing applications because unfortunately older versions of PHP litter the internet primarily due to the one .ini to rule them all (per server.)

    PHP is a prime example of how over-simplification can actually lead to more complication.

Leave a comment on “Can You Say Your $a, $b, $c's?”

Log In or post as a guest

Replying to comment #:

« Return to Article