Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-05 Thread Stefan Karpinski
The notion of types as sets of values and subtyping as a subset relation is not quite so simple as it initially sounds. The issue is that unlike the world of mathematics, programs aren't static and fixed forever. If we just the subset notion at face value, we'd get this sort of thing: abstract A

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-05 Thread Stefan Karpinski
Also as Ray pointed out, if subtypes returned a union, it would not be returning a collection of types as the name would suggest but rather a single type. On Tue, Jan 5, 2016 at 9:42 AM, Stefan Karpinski wrote: > The notion of types as sets of values and subtyping as a

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-04 Thread Ray Toal
All good, but I just can't see it. If I have: julia> abstract T julia> type S <: T; end julia> type R <: T; end and I ask "What are the subtypes of T?" I would expect to get back either [S,R] or [R,S] or even Set{R,S} because each of those things have cardinality 2. Because there are 2

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-04 Thread Ismael VC
Just my thoughts: - You can’t have Set{R, S} only Set{T}, Set{DataType}([R, S]) for example. - The moment you want to dispatch on those subtypes you would need to do something like Union{Ts...}, where Ts is an array or set of such subtypes. - Union{R, S} == Union{S, R} is true.

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-04 Thread Ismael Venegas Castelló
After watching the video: *Jeff Bezanzon: Julia - The base language, future directions and speculations *as Scott mentions, returning a Union type indeed starts to make sense to me. El sábado, 2 de enero de 2016, 13:09:43 (UTC-6), Scott Jones

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2016-01-02 Thread Scott Jones
Going by Jeff's JuliaCon 2015 talk, and the code in examples/JuliaTypes.jl, I think returning the subtypes as a set of types (which is the same as a union of types) makes perfect sense. I'm hoping that this change does make it into 0.5, I think it does clean up a lot of bad corner cases in the

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-29 Thread Ray Toal
But maybe I'm not understanding this correctly? Was it suggested that a type union be the result of the subtypes method? I don't think that makes sense The subtypes of a type is a set of types, not a type (even if that type were the union of all the subtypes). It strikes me as a little

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-29 Thread Mauro
I think Scott meant a type union: julia> Union{Int,Float64} Union{Float64,Int64} julia> Int<:ans true which is itself a type. On Tue, 2015-12-29 at 00:53, Ismael VC wrote: > I thougt one advantage of using sets would be the ability to use set > operations, but they

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Scott Jones
How would this fit in with Jeff's work on types/subtypes? At JuliaCon he did talk about improving the type system (something I've been really hoping to see). It seems to me that it might be more logically consistent to return a type union for this, but I understand that currently it is easier to

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Stefan Karpinski
No, please don't spend time on this. We're not going to change this to return a heavyweight data structure like a Set when a simple structure like and Array will do. In mathematics sets are simpler than ordered collections, but in programming languages the relationship is reversed. In general data

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Ismael Venegas Castelló
Stefan, wouldn't using `sort!` instead of `sort` be better here in this case?: subtypes(m::Module, x::DataType) = sort(collect(_subtypes(m, x)), by=string) subtypes(m::Module, x::DataType) = sort!(collect(_subtypes(m, x)), by=string) El lunes, 28 de diciembre de 2015, 9:25:08 (UTC-6),

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Stefan Karpinski
Sure. That avoids unnecessarily copying the array. On Mon, Dec 28, 2015 at 10:51 AM, Ismael Venegas Castelló < ismael.vc1...@gmail.com> wrote: > Stefan, wouldn't using `sort!` instead of `sort` be better here in this > case?: > > subtypes(m::Module, x::DataType) = sort(collect(_subtypes(m, x)),

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Ismael VC
Ok then I'll make a PR for that, and see if I find more uses like this that can be changed. Ismael Venegas Castelló *Data Analyst* Cel. 044 55 6434 0229 ivene...@richit.com.mx Cerro San Francisco 357, C.P. 04200 Campestre Churubusco, Coyoacán Ciudad de México

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-28 Thread Ismael VC
I thougt one advantage of using sets would be the ability to use set operations, but they work on arrays to, by the way the documentation of ie, union falls short, because it’s actually more general than what it says (*not only sets*): help?> union search: union union! Union @unix_only function

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Ray Toal
Ah, I didn't think about performance. I was simply thinking that sets make more sense semantically when the order does not matter, and arrays or lists make sense when the order does matter. I thought there would be no point in using an array for unordered items, but it sounds like the point is

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Ismael VC
Kevin I tested in my Win laptop with 0.3.11, 0.4.2, 0.4, 0.5+ also the same versions in julia box, and the output is deterministically sorted, It seems this has been the way it works for some time now, then I looked at the code and it’s indeed sorted (should have done that first! :P ): -

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Kevin Squire
Ray, thanks for the clarification--makes sense. In fact, for introspection code like 'subtypes', performance is probably the wrong argument--it's unlikely that it occurs in performance-critical code. I think it's really that arrays are just simpler. One aesthetic change I could imagine would be

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Kevin Squire
Thanks for looking and posting (I've been on my phone). I think I might have written that code, actually. ;-) Cheers! Kevin On Sunday, December 27, 2015, Ismael VC wrote: > Kevin I tested in my Win laptop with 0.3.11, 0.4.2, 0.4, 0.5+ also the > same versions in

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Ray Toal
I'm sure the order won't ever change, but I'd still find it odd if the documentation of subtypes were to say "Returns a list of subtypes, sorted by the name of the subtype" because, well, what about namespaces? What about all sorts of Unicode collation definitions that would have to be a part

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-27 Thread Kevin Squire
Hi Ray, You're probably the first person to make this observation. I can see your point, and I don't really have a strong argument or opinion, really--the main reason it's sorted is probably because it looks nicer--at least if I did write that code, that would have been my reasoning. If you're

[julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-26 Thread Ray Toal
I noticed that *julia> **subtypes(Type)* *3-element Array{Any,1}:* * DataType * * TypeConstructor* * Union * and was wondering if there was any significance in the order of the subtypes. If not, could the method have produced a Set instead?

Re: [julia-users] Why does the subtypes method produce an array rather than a set?

2015-12-26 Thread Kevin Squire
On Saturday, December 26, 2015, Ray Toal wrote: > I noticed that > > *julia> **subtypes(Type)* > > *3-element Array{Any,1}:* > > * DataType * > > * TypeConstructor* > > * Union * > > and was wondering if there was any significance in the order of the > subtypes. If not,