[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: false and types
- To: email@example.com, firstname.lastname@example.org
- Subject: Re: false and types
- From: email@example.com (Andrew LM Shalit)
- Date: Thu, 22 Oct 1992 18:35:12 -0500
At 2:09 PM 10/22/92 -0700, firstname.lastname@example.org wrote:
> (define-class <foo> (<object>)
> (a type: <integer>
> init-value: #f)) ;; Why can you do this...
> ;Value: <foo>
This is an error. Thomas should not let you do this.
> (define foo (make <foo>))
> ;Value: foo
> (a foo)
> ;Value: ()
> ((setter a) foo 3)
> ;Value: 3
> ((setter a) foo #f) ;; ...if you can't do this?
> I figured out that I could do (singleton #f) to create a type for
> a method that dispatched specifically on false, but that isn't
> a solution for the above. In C and C++ NILL is kind of an exception
> to the type system, and I thougth #f might play the same role.
> What is the *right* thing to do?
In this case, the right thing to do in Dylan is to not supply an
init-value. If the slot is accessed before a value is stored in
it, you will get an error.
If you want to supply an init value, it must be of the type specified
for the slot.
I thought the Dylan manual was clear about this, but a quick glance
shows that it doesn't spell out the restriction on init-value specifically.