<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 3, 2016 at 10:35 AM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Again, playing Devil's Advocate... maybe we want a concept of<br>
"undefined" like in Javascipt.<br>
<br>
result: Type = undef<br>
<br>
which would make it clear that this is a type declaration, and that<br>
result is still undefined.<br></blockquote><div><br></div><div>I like this -- and we need to change the interpreter anyway. I take it this would be a no-op at run time?</div><div><br></div><div><br></div><div>Though I'm still on the fence -- it's a common idiom to use None to mean undefined. </div><div><br></div><div>For example, I at least, always thought is was better style to do:</div><div><br></div><div>class Something():</div><div> an_attribute = None</div><div><br></div><div>and then:</div><div><br></div><div>if self.an_attribute is None:</div><div> ....</div><div><br></div><div>Than not predefine it, and do:</div><div><br></div><div>if not hasattr(self, 'an_attribute'):</div><div> ....</div><div><br></div><div>granted, I only do that for class (or instance) attributes in real code, not all names.</div><div><br></div><div>So do we really need to support "this variable can be undefined, but if it is defined in can NOT be None?</div><div><br></div><div>Are there really cases where a variable can't be None, but there is NO reasonable default value?</div><div><br></div><div>Or are folks hitting a limitation in the type checker's ability to deal with None?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Disadvantages:<br>
<br>
- Javascript programmers will think you can write `print(result)` and<br>
get "undef" (or similar);<br>
</blockquote><div><br></div><div>Do we care about that????</div><div><br></div><div>BTW, does JS have a None? or is 'undef' its None?</div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>