Technically the empty string is the 1 of the string monoid. The point being
that the correct default value depends on what you're doing. If we were
going to have a default value function, it should be a different thing. I'm
not convinced that we should encourage default values, however. They strike
me as slightly sketchy.


On Thu, Feb 27, 2014 at 9:54 AM, Iain Dunning <iaindunn...@gmail.com> wrote:

> Maybe implementing zero for strings could be a good idea... I've
> implemented it for a few custom types, but theres always been a fairly
> unambiguous meaning of what it means to be zero.
>
>
> On Thursday, February 27, 2014 2:15:04 AM UTC-5, Avik Sengupta wrote:
>>
>> Well, there is zero(..) but that is defined only for numeric types
>>
>> julia> zero(Int64)
>> 0
>>
>> julia> zero(ASCIIString)
>> ERROR: no method convert(Type{ASCIIString}, Int64)
>>  in zero at operators.jl:146
>>
>> julia> zero(Float64)
>> 0.0
>>
>> On Thursday, 27 February 2014 06:25:39 UTC, Fil Mackay wrote:
>>>
>>> Is there an easy way, given a particular intrinsic Type, to create a
>>> default (zero) instance? eg.
>>>
>>> z(Int64)
>>> # 0::Int64
>>>
>>> z(ASCIIString)
>>> # ""::ASCIIString
>>>
>>> Akin to the C# default 
>>> keyword<http://msdn.microsoft.com/en-us/library/xwth0h0d.aspx>,
>>> that returns the default initialised value of any type.
>>>
>>>

Reply via email to