Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming:
From: Thomas Gagne (tgagne_at_wide-open-west.com)
Date: 07/12/04
- Next message: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Previous message: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- In reply to: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Next in thread: Dmitry A. Kazakov: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 12 Jul 2004 13:36:30 -0400
Mark S. Hathaway wrote:
> Dmitry A. Kazakov wrote:
>
>>> How about performing math on Strings. Would that be unusual? Using
>>> the regular mathmatical expression in the language so you could:
>>>
>>> basket = ("apple" * 5) + ("orange" * 2);
>>
>>
>>
>> The result is: "appleappleappleappleappleorangeorange", which is
>> definitely
>> not a basket, so the result is FALSE (provided that "=" is as in
>> mathematics a equality test).
>>
>> BTW, using Number and String in the same operation (here "*"), is
>> *not* the
>> same as mixing them interchangeable. The former is quite normal, for
>> example in Ada String * Number gives String. The latter is in 99% just an
>> error, a type error.
>>
>
> Aaaaarrrrrrgggghhhhhhhhhh! You were ahead of me. :-)
>
> But, why is the answer not a 'basket'. After all, 'basket'
> is just a label/name on an object and has no inherent type.
> It just points to some object which could be anything.
>
> basket=3
> basket='string'
> basket=TRUE
>
> basket is a name, not a type.
>
> I suppose we should also ask, why is 'apple' the dominant object
> in the parenethesized phrase? why isn't it a type error because
> the number 2 cannot be multiplied by a non-number?
You're right about basket just being the name of a variable. It had no type
until after the assignment.
I think Dmitry was saying the multiple dispatch would be a good thing and
would benefit from static typing if we knew what basket was intended to be. I
only intended it to be whatever the result of the operation was.
The result I intended an expression with unsolved for variables named "apple"
and "orange". The fact people know what apples and oranges are is beside the
point. It could just as easily been x and y, but I've always wanted to add
apples and oranges.
In any case, I can multiple "2 * 'apple'" and "'apple' * 2". If I wanted I
could multiply 'apple' * 'orange' (x * y) and get 'appleorange' (xy).
See earlier reply for why I might consider doing it in the first place.
- Next message: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Previous message: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- In reply to: Mark S. Hathaway: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Next in thread: Dmitry A. Kazakov: "Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP and memory management"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|