Ok, makes sense!

On Saturday, February 15, 2014, Johan Sigfrids <[email protected]>
wrote:

>
>
> On Saturday, February 15, 2014 8:49:01 PM UTC+2, Kevin Squire wrote:
>>
>> You might have figured this out by now, if you have a parameterized
>> family of types Degree{T}, there is no unparameterized version
>> available, so you either have to
>>
>> 1) provide a default constructor which creates the proper parameterized
>> type
>>
>> Degree{T<:Number}(d::T) = Degree{T}(d)
>>
>> This is a parameterized *function* taking a parameter d, from which the
>> type T is inferred, and calls the constructor for *type* Degree{T} (the T is
>> part of the type).  The function can then be called with Degree(num).
>>
>
> I thought such a constructor was provided by default.
>
>
> Actually, my mistake was simpler than that. 150° is parsed as 150 * ° to
> make writing mathematical formulas easier, but i° is simply parsed as a
> variable named i°. My constructor trick only work with numeric literals. :(
>
> It does leave the question of why
>
> [undefine_variable for i in 1:10]
>
> throws and error while
>
> for i in 1:10
>     undefined_variable
> end
>
> doesn't.
>

Reply via email to