<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>A type denotes a set of allowable values. The NULL type is the set of values that only contains the value NIL. You need it because every expression has a static type so you need one for the expression "NIL".</div><div><br></div><div>This to me looks like a bug. I have something similar in my code, declared CONST Nil: REFANY = Nil; so I can write PROCEDURE(a, b, c := Nil). Maybe that's what they had in mind but thinking the type of NIL was REFANY.</div><div><br></div><br><div><div>On Apr 22, 2013, at 10:38 AM, Jay K wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 12pt; font-family: Calibri; "><div dir="ltr">Disclosure: I knew they are of type "NULL", but I didn't/don't know what that type is, or have a mental model for it.<br>This about the only place in the entire tree that uses this type. It triggers an error in the C backend, but should be trivial to fix. I can just treat this as "ADDRESS" presumably. Checks that it is NIL, that is the frontend's job. The error is just that I check that I know about every type. Some types are "predeclared", some come from the frontend. I'll predeclare this. Arguably nothing should be predeclared.<br> <br> <br> - Jay<br> <br><div><div id="SkyDrivePlaceholder"></div>> Date: Sun, 21 Apr 2013 21:03:02 -0500<br>> From:<span class="Apple-converted-space"> </span><a href="mailto:rodney_bates@lcwb.coop">rodney_bates@lcwb.coop</a><br>> To:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] null type?<br>><span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>><span class="Apple-converted-space"> </span><br>> On 04/21/2013 03:55 PM, Jay K wrote:<br>> > What is the meaning of this:<br>> ><br>> > cm3/elego/graphicutils/src/RsrcFilter<br>> ><br>> > init(p1, p2, p3, p4, p5, p6 := NIL) : T;<br>> > (* Initializes the resource search path. *)<br>> ><br>> ><br>> > PROCEDURE Init(self : T; p1, p2, p3, p4, p5, p6 := NIL) : T =<br>> ><br>><span class="Apple-converted-space"> </span><br>> Modula-3 says:<br>><span class="Apple-converted-space"> </span><br>> 2.2.7: 'The following reference types are predeclared:<br>> ...<br>> NULL Contains only NIL'<br>><span class="Apple-converted-space"> </span><br>> And:<br>><span class="Apple-converted-space"> </span><br>> 2.2.8: 'A formal parameter declaration has the form<br>> Mode Name: Type := Default<br>> ...<br>> If Type is omitted, it is taken to be the type of Default.'<br>><span class="Apple-converted-space"> </span><br>> And:<br>><span class="Apple-converted-space"> </span><br>> 2.6.6: 'The literal "NIL" denotes the value NIL. Its type is NULL.'<br>><span class="Apple-converted-space"> </span><br>> So all the pi's have type NULL, and only NIL can be passed to them<br>> as actuals. That's what the language says. It looks like the code<br>> in Init thinks it can get non-NIL reference values, but an attempt to pass<br>> one in a call should fail a runtime assignability check, since it<br>> won't be a member of NULL.<br>><span class="Apple-converted-space"> </span><br>> When Init passes one of these to Convert (Yes, I peeked into<br>> RsrcFilter.m3), it is assignable, with no runtime check. Convert<br>> thinks it has a REFANY, and other calls to Convert could indeed<br>> give it something non-NIL, but not from the calls in Init.<br>><span class="Apple-converted-space"> </span><br>> Of course, unsafe code could probably LOOPHOLE (remember, any word<br>> can be verbed) something non-NIL to NULL and pass it to init/Init.<br>> If the compiler did the most obvious thing, this might do what was<br>> apparently intended.<br>><span class="Apple-converted-space"> </span><br>> But then again, a compiler would be fully compliant with the language<br>> and perfectly within its rights to optimize out such a parameter,<br>> not actually pass it at runtime at all, and just insert constant NIL<br>> wherever the formal was referenced in the body of Init, thus undermining<br>> the above intent.<br>><span class="Apple-converted-space"> </span><br>> Which makes for a good example of how unsafe code (almost?) always<br>> depends on assumptions about what a compiler will do.<br>><span class="Apple-converted-space"> </span><br>> ><br>> > What are the types of p1, p2, etc.?<br>> ><br>> ><br>> > - Jay<br>><span class="Apple-converted-space"> </span><br></div></div></div></span></blockquote></div><br></body></html>