type inference for dynamic

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

type inference for dynamic

Robin Palotai
Hi!

When I have a Dynamic x, and do a trace("x:" + x), then the type of x
gets assumed to be a String.
Is this expected behaviour?

Thanks!
Robin

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: type inference for dynamic

Benjamin Dasnois
Hello Robin,

are you sure you declared your var as a Dynamic ? For example with var
x : Dynamic; ? Because Dynamic actually is a type and when a var is
known to be a Dynamic then there's no more type inference on it. Type
inference only occurs when type is Unknown.

Regards,

On Tue, Nov 4, 2008 at 12:20 AM, Robin Palotai <[hidden email]> wrote:

> Hi!
>
> When I have a Dynamic x, and do a trace("x:" + x), then the type of x
> gets assumed to be a String.
> Is this expected behaviour?
>
> Thanks!
> Robin
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



--
DASNOIS Benjamin
http://www.benjamindasnois.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: type inference for dynamic

Robin Palotai
Sorry, you are right. I used Type.createInstance() so it should be Unknown.
Thanks!
Robin

On Tue, Nov 4, 2008 at 12:31 AM, Benjamin Dasnois
<[hidden email]> wrote:

> Hello Robin,
>
> are you sure you declared your var as a Dynamic ? For example with var
> x : Dynamic; ? Because Dynamic actually is a type and when a var is
> known to be a Dynamic then there's no more type inference on it. Type
> inference only occurs when type is Unknown.
>
> Regards,
>
> On Tue, Nov 4, 2008 at 12:20 AM, Robin Palotai <[hidden email]> wrote:
>> Hi!
>>
>> When I have a Dynamic x, and do a trace("x:" + x), then the type of x
>> gets assumed to be a String.
>> Is this expected behaviour?
>>
>> Thanks!
>> Robin
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>
>
>
> --
> DASNOIS Benjamin
> http://www.benjamindasnois.com
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: type inference for dynamic

Nicolas Cannasse
Robin Palotai a écrit :
> Sorry, you are right. I used Type.createInstance() so it should be Unknown.

To be exact on this point, Type.createInstance() returns a Dynamic type,
but the Dynamic type does not propagate, so it immediately becomes an
Unknown.

Nicolas

--
haXe - an open source web programming language
http://haxe.org