Re: [julia-users] Re: returning an #undef

2014-10-09 Thread David van Leeuwen
Hi, On Thursday, October 9, 2014 5:02:06 PM UTC+2, Stefan Karpinski wrote: > > On Thu, Oct 9, 2014 at 8:50 AM, Ivar Nesje > > wrote: > >> How can I return #undef from a function? >> >> > > You will have to modify the internals of Julia so that *#undef* becomes a >> value that can be passed ar

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Stefan Karpinski
That is a problem for this representation – we would need to support matrix resizing to add and remove nodes. In general, adding and removing nodes is inefficient. On Thu, Oct 9, 2014 at 12:03 PM, John Myles White wrote: > When you add a new node in this representation, do you reshape to a > vec

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread John Myles White
When you add a new node in this representation, do you reshape to a vector, resize the vector, then reshape to a matrix again? -- John On Oct 9, 2014, at 8:55 AM, Stefan Karpinski wrote: > The self-link-is-null-link solution only works when the structure is acyclic > (or more specifically wh

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Stefan Karpinski
The self-link-is-null-link solution only works when the structure is acyclic (or more specifically when nodes cannot validly link to themselves). You only need to have null links when there's a fixed number of link "slots" – if the number of links is a variable-sized array, you can just use an empt

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread John Myles White
I'll add that to the list of better ways to handle recursive data structures. This is why I think we need a longer exposition on best practices for representing "absent" things. People have come up with a lot of different approches out in the wild so far. -- John On Oct 9, 2014, at 8:44 AM, T

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Tim Holy
On Thursday, October 09, 2014 08:19:19 AM John Myles White wrote: > And the use of things like an EmptyTree type in DataStructures.jl means that > absence is also being represented in a type-unstable way in some packages. > (https://github.com/JuliaLang/DataStructures.jl/blob/master/src/tree.jl) O

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Stefan Karpinski
But yes, I agree, we have not yet fully figured out (let alone documented) the Nullable business. It is, after all, only functionality that's less than a month old. On Thu, Oct 9, 2014 at 11:34 AM, Stefan Karpinski wrote: > On Thu, Oct 9, 2014 at 11:19 AM, John Myles White < > johnmyleswh...@gma

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Stefan Karpinski
On Thu, Oct 9, 2014 at 11:19 AM, John Myles White wrote: > People have started using isdefined in non-Base code, which I think is the > first step towards #undef becoming a de facto first-class citizen. This is actually not such a big deal since you still can't return it from a function or assi

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread John Myles White
On julia-dev, I've been asking questions to help me flesh out a formal policy for representing NULL-ness as it occurs in many common situations. I think a full FAQ entry will need to be a whole section of the manual (i.e. the section on Nullable{T}), covering things like missing values in statis

Re: [julia-users] Re: returning an #undef

2014-10-09 Thread Stefan Karpinski
On Thu, Oct 9, 2014 at 8:50 AM, Ivar Nesje wrote: > How can I return #undef from a function? > > You will have to modify the internals of Julia so that *#undef* becomes a > value that can be passed around. Currently it isn't, but we have a new > concept in 0.4-dev with nullable types >

[julia-users] Re: returning an #undef

2014-10-09 Thread Ivar Nesje
> > How can I return #undef from a function? You will have to modify the internals of Julia so that *#undef* becomes a value that can be passed around. Currently it isn't, but we have a new concept in 0.4-dev with nullable types that