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


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.



Relevant Pages

  • Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming:
    ... > Dmitry A. Kazakov wrote: ... You're right about basket just being the name of a variable. ... The result I intended an expression with unsolved for variables named "apple" ... The fact people know what apples and oranges are is beside the ...
    (comp.object)
  • Re: Class Hierarchy design problems...
    ... My opinion is that your intent doesn't make sense. ... How does the fact that the apple is in a basket influence the nature of the ... Is it THAT MUCH more elegant than writing the following? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: OT: Thanksgiving Dinner
    ... I hope you are using something to cancel the all that acid base from oranges ... Keep the apple inside and use lemon or orange slices stuffed under the ...
    (rec.pets.cats.anecdotes)
  • Re: Question about light clock and derivation of time dilation
    ... >> Unfortunately, with morons like Androcles and Wilson, ... Indeed there are no negative time intervals anymoe than there are ... negative apples or negatove oranges, ... If you received one apple every orange in the last seven ...
    (sci.physics.relativity)
  • Re: The king of france is ...
    ... in my basket are red" is true when there are no apples in the basket. ... I'm not convinced that we always interpret such sentences as having an ... implicit claim that there are more than one apple in my basket. ...   ...
    (sci.logic)

Loading