Typechecking with structures/ enumerations

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
soerenkj
User
User
Posts: 95
Joined: Mon Jun 14, 2004 10:19 pm

Typechecking with structures/ enumerations

Post 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
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post 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.
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

I'll cry if this is implimented :?
I use and abuse extended structures w/ pointers...
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post 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
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
soerenkj
User
User
Posts: 95
Joined: Mon Jun 14, 2004 10:19 pm

Post 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)
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

Maybe warnings instead of errors would be good, so you can simply skip and ignore them if you wan't.
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
Post Reply