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

Re^5: "strong typing" is potentially ambiguous

by sleepingsquirrel (Chaplain)
on Dec 15, 2004 at 16:50 UTC ( [id://415107]=note: print w/replies, xml ) Need Help??


in reply to Re^4: "strong typing" is potentially ambiguous
in thread (Completely OT) - Hero(i)n programming language on Slashdot

So, in your example, the operation '+' isn't defined for the value "dog". However, let's say we had the operation '_' (string concatenation). It would be defined for "dog" ... it could also be defined for "3.14". So, the statement 3.14 _ "dog" could have meaning ... right?
Yes, that could have meaning. If you're the person designing the type system, you get to decide which statements have meaning. So you weigh the trade-offs. On the one hand, allowing the use of '+' in a statement like 3.14 + "dog" has the advantage of being short and sweet; easy for the programmer to type, and it reduces the number of operators/functions he has to learn. And if the programmer has a question about the semantics, he can look it up in the manual. On the other hand, you ask if it is really so much trouble to break that operator into two separate ones: stringify(3.14) + "dog" or 3.14 + numify("dog") . Now the programmer is forced to make his intentions explicit in the code, rather than implicit (i.e. in the documentation). Is one method better/faster/cleaner/buggier than the other? You get to decide (but be forewarned, that's the stuff of holy wars).


-- All code is 100% tested and functional unless otherwise noted.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-20 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found