So going deeper into using my own types, and coding style in julia.

Lets say I have the container type

type Foo


On Monday, June 20, 2016 at 7:10:15 AM UTC-7, Gabriel Gellner wrote:
>
> That was what I was feeling. That this was a legacy issue for lowercase 
> type "constructors". Thanks so much.
>
> On Monday, June 20, 2016 at 1:11:41 AM UTC-7, Mauro wrote:
>>
>> I think you should use the constructors if the user expects to construct 
>> a certain type, e.g. `Dict()`.  Conversely if the user cares about the 
>> action then use a function, e.g.: 
>>
>> julia> keys(Dict()) 
>> Base.KeyIterator for a Dict{Any,Any} with 0 entries 
>>
>> here I don't care about the type, I just want to iterate the keys. 
>>
>> But of course, it's not that clear-cut: `linspace` has history, so does 
>> `zeros`.  So, for a new container type I'd use the constructor `FooBar`. 
>>
>> On Sun, 2016-06-19 at 23:12, Gabriel Gellner <gabriel...@gmail.com> 
>> wrote: 
>> > I am currently making some container like types, so I am using the 
>> > convention of studly caps for  the types ie `FooBar`. For usage I am 
>> > confused on what the julian convention is for having expressive type 
>> > constructors like for `Dict` and `DataFrame`, versus using methods like 
>> > `linspace`. Clearly I could use either, but it is not clear to me when 
>> I 
>> > should use one convention over the other. 
>> > 
>> > Clearly I can have my api be like: 
>> > 
>> > f = FooBar(...) 
>> > 
>> > or 
>> > 
>> > f = foobar() 
>> > 
>> > but is one preferred over the other? Is it just random when to use one 
>> or 
>> > the other when making container like types? 
>>
>

Reply via email to