Abstract/Final

BlitzMax Forums/BlitzMax Beginners Area/Abstract/Final

Smurftra(Posted 2006) [#1]
Question:

In blitzmax help, i noticed the AbstractType and FinalType keywords. I tried using them and my program doesnt compile anymore. It says

Syntax error in user defined type declaration

so i guess its in the help file and isnt really implemented or was removed?

this does not compile and i figured it would:

Type AbstractType TTest
Field X:Int
End Type


thanks


Dreamora(Posted 2006) [#2]
Type Test abstract
...
end type

type Test final
...
end type

abstract can be used for method / function declaration as well (but then without any function body, just the declaration)

see max2d driver for an implementation and "show of" on how to use its power.


Grey Alien(Posted 2006) [#3]
yeah you basically screwed up :-D It should be

Type TypeName Abstract
or 
Type TypeName Final


as Dreamora shows. I've used Abstract for a couple of types that don't really do anythig on their own, they need to be extended. But I haven't found a use for Final yet.


Dreamora(Posted 2006) [#4]
The use of final is when you create a class that you want to be not-extendable. This could be for example because it has some strange cross relations that would break on extending (as an outside user of a module would not know of that) or just because you don't want the user to steal your work and create "wrapped" classes for it.

Don't know if C++ knows of a similar mechanism, Eiffel does it for sure.


H&K(Posted 2006) [#5]
Yes c++ does it as well


Smurftra(Posted 2006) [#6]
oh you guys are right i messed up the from the example, dang dylsexia ;)