[DGD]1.1.52

Mikael Lind z94lind at mtek.chalmers.se
Sat Mar 13 19:29:20 CET 1999


On Sat, 13 Mar 1999, Felix A. Croes wrote:

> Mikael Lind <z94lind at mtek.chalmers.se> wrote:
> 
> >[...]
> > On another (but related) subject: will DGD ever support a boolean type? I
> > would like that very, very much. 
> 
> You're not the only one who has asked for this, but a boolean type
> doesn't mix very well with LPC's C-derived operators.  As you may
> know, LPC before DGD has a `status' type which I chose to eliminate
> rather than make into an actual boolean type.
> 
> What exactly do you see as the advantages of a bollean type?

I haven't analyzed this. At the moment, my need for a boolean type in a
programming language is perhaps emotional rather than intellectual. I'll
try to explain. 

Take the recent addition of a null value (nil) to DGD. Before this
happened, integer 0 was used as a substitute for a nil value. Practically,
this worked fine in most cases, only occasionally requiring a work-around.
Logically, however, a string variable (for instance) holding an integer
value didn't appeal to me at all. So, I really appreciated the addition of
nil to DGD. Letting nil test as false in conditionals was the perfect
thing to do - in the context of already using integer as a substitute for
boolean, and previously have been using 0 as a substitute for null.

All in all, adding nil was a major improvement in DGD's strictness. Which,
sort of, brings me back to the need for a boolean type. I don't see any
reason for using a boolean type apart from being strict.

This is my current situation: When I code LPC, logical expressions don't
evaluate to true or false, but rather to integer 1 or 0. I don't think of
conditionals as requiring a boolean value, because they really don't. For
instance, a construction such as

    if (string_value) {
        print(string_value + "\n");
    }

is logically hairy but practically useful. I use it all of the time. But I
don't like it. There is of course the elegant alternative

    if (string_value != nil) {
        print(string_value + "\n");
    }

I could use this, but I don't want to. Since the interpretations of 
the tests are identical, I prefer the shorter form. This is something that
may or may not make sense to you. 

I'd like to stop here and request feedback. It is my opinion that the
introduction of a boolean type would improve clarity in code. I also think
that a certain amount of strictness in a programming language such as LPC
is solely positive. Unfortunately, I feel like I'm having a hard time
formulating my thoughts on the subject. Can anyone tell me what I'm trying
to say? 

// Mikael

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list