Page 1 of 1

Typechecking with structures/ enumerations

Posted: Wed Sep 15, 2004 8:48 am
by soerenkj
when I do like the following, the compiler doesn't complain...

Code: Select all

Structure Test1 : x.l : EndStructure
Structure Test2 : y.l : EndStructure
Procedure Foo(*t1.Test1) : EndProcedure
t2.Test2
Foo(@t2)
I guess there is some reason for that (something about extended structures?), but I would be nice if it was checked..

another thing, probably even more far out:
I would like to be able to give names to enumation blocks, and that the type could be checked accordingly by the compiler, like this:

Code: Select all

Enumeration Vehicle : #Car : #Truck : EndEnumeration
Procedure Foo(type.Vehicle) : EndProcedure

Posted: Wed Sep 15, 2004 10:00 am
by GedB
Having all the flexibility with Structures is one of the fun things about PureBasic. It gives a lot of freedom.

If strong typing is something you would like to have, why not take a look at Eiffel.

SmartEiffel produces small and fast executables. It's also free and open source. You might like it:

http://smarteiffel.loria.fr/

The main problem is no GUI. The new release in Beta features a vision library, but I can't get it to work.

A good approach is to use Purebasic for the GUI, which I'm working on refining.

Posted: Wed Sep 15, 2004 11:04 am
by PolyVector
I'll cry if this is implimented :?
I use and abuse extended structures w/ pointers...

Posted: Wed Sep 15, 2004 7:34 pm
by Codemonger
I hate strong type checking with a passion, pls. never implement it. Then type defining will be implemented and people will be making their own types instead of using descriptive variable names ... :cry: it's a tragedy

Posted: Thu Sep 16, 2004 9:08 am
by soerenkj
I agree with you all, the flexibility of PB is great - strong typing is merely an 'academic quest'...
however, in this particular case I think no harm is done - in the code I specifically say that I'm expecting a Test1-structure and I could be very unhappy if that isn't the case.. (and I really have no way of checking myself if it is the right type of structure I'm getting..)
in an implementation the compiler perhaps should also accept structures that are 'extended' from Test1 (but personally I don't need that anymore, since I found 'StructureUnion's)

Posted: Sun Sep 19, 2004 3:06 pm
by tinman
I'd be happy to see it if you could enable or disable it as required. Or perhaps have the compiler flag it up as a warning rather than an error. Or perhaps you could get around it on a case by case basis by adding some compiler token to say that yes, I really really mean to pass the wrong type here.

Posted: Mon Sep 20, 2004 7:11 pm
by Codemonger
Maybe warnings instead of errors would be good, so you can simply skip and ignore them if you wan't.