Julia vs. D?

via Digitalmars-d digitalmars-d at puremagic.com
Wed May 7 02:18:05 PDT 2014


On Wednesday, 7 May 2014 at 07:27:42 UTC, Mason McGill wrote:
> On Tuesday, 6 May 2014 at 21:00:18 UTC, bearophile wrote:
>> The language tries its best to be flexible as a dynamic 
>> language. But variables never carry a run-time type tag, 
>> unlike in Lisp.
>
> Hmm... Then how can I do this:
>
>   x = 5
>   typeof(x) # evaluates to "Int64"
>   x = 5.0
>   typeof(x) # evaluates to "Float64"
>
> ?
>
> Is Julia doing something trickier than I think it is? Or do you 
> just mean they don't carry type tags after compilation?

Maybe the first x stops existing, and a new one is created on 
reassignment?

A more interesting case is this (pseudo code, don't know Julia 
syntax):

     x = 5
     if (...) {
         x = "Hello"
     }
     typeof(x) # ???

Is that disallowed?


More information about the Digitalmars-d mailing list