I see.  Thanks Toivo and Ivar.

On Tue, 2014-10-21 at 13:10, Ivar Nesje <[email protected]> wrote:
> This seems like a very similar issue to the various issues about the `=` in 
> keyword argument parsing to a different expression than `=` in an 
> assignment. They print equal, but parse to different expressions, depending 
> on the context. Not sure what Jeff want to do, but it seems likely that we 
> ultimately would like to use the same expressions for the same syntactic 
> elements.
>
> Ivar
>
>
>
> kl. 12:54:43 UTC+2 tirsdag 21. oktober 2014 skrev Mauro følgende:
>>
>> > What is Expr(:<:, :X, :Int) supposed to mean? 
>>
>> It's part of a function definition: 
>>
>> :(f{X<:Int}(x::X) = 5).args[1].args[1].args[2] 
>>
>> I came across this when doing unit testing for a function which picks a 
>> function definition apart: 
>>
>> julia> parsef(fn) = fn.args[1].args[1].args[2] 
>> parsef (generic function with 1 method) 
>>
>> julia> fn = :(f{X<:Int}(x::X) = 5) 
>> :((f{X<:Int})(x::X) = 5) 
>>
>> julia> parsef(fn) 
>> :(X<:Int) 
>>
>> julia> @test parsef(fn)==:(X<:Int) 
>> ERROR: test failed: (X<:Int == X <: Int) 
>>
>> julia> @test parsef(fn)==Expr(:<:, :X, :Int) 
>> # passes test 
>>
>> > 
>> > I just get an AST error when trying to evaluate that expression, so it 
>> > can't be very usefull 
>> > 
>> > julia> eval(Expr(:<:, :Int64, :Int)) 
>> > ERROR: unsupported or misplaced expression <: 
>> > 
>> > We should probably consider erroring out when printing invalid 
>> expressions. 
>> > 
>> > Regards 
>> > Ivar 
>> > 
>> > kl. 11:05:34 UTC+2 tirsdag 21. oktober 2014 skrev Mauro følgende: 
>> >> 
>> >> This seems a bit confusing: 
>> >> 
>> >> ``` 
>> >> julia> Expr(:<:, :X, :Int) 
>> >> :(X<:Int) 
>> >> 
>> >> julia> Expr(:<:, :X, :Int).head 
>> >> :<: 
>> >> 
>> >> julia> :(X<:Int) 
>> >> :(X <: Int) 
>> >> 
>> >> julia> :(X<:Int).head 
>> >> :comparison 
>> >> ``` 
>> >> 
>> >> Is this intentional?  This also means that copy-pasting the string 
>> >> representation of `Expr(:<:, :X, :Int)` does not yield itself. 
>> >> 
>>
>>

Reply via email to