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 <[email protected] <javascript:> > > 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 >> <http://docs.julialang.org/en/latest/manual/nullable-types/> that might >> suit your need. >> > > Please don't try to actually do this – the fact that #undef is not a > first-class value is very much by design. Tony Hoare has given entire > talks > <http://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare> > about > why including null references as first class values in Algol was a "billion > dollar mistake", which was of course, then copied by C, Java, etc. This > should perhaps go in our FAQ. >
I won't, I promise. I just got in the cycle of needing to find out what the REPL default show() is for my <: AbstractArray type, which seems pretty complicated, but one of the requirements appears to be the implementation of similar(), which, from the documentation, needs to produce a unitialized array. So that's how I ended wanting to be able to produce something uninitialized. BTW I'm still not there, I am now at a definition Base.writemime(io::IO, m::MIME"text/plain", w::WarpedArray) = writemime(io, m, array(w)) which makes my WarpedArray object at least displayable in the REPL, but I have the feeling this is not the right hook I am using. ---david
