Types within classes

| | Comments (1)

One of the more often-requested compiler features has been implemented in 2008 Release 3, which is the ability to put types within classes. This means that you can create structures, enumerations and delegates all inside of a class, instead of only within a module. Very handy stuff!

One thing someone asked during the dev cycle for this was: "why can't I put these into an interface?" The reason is: interfaces make a contractual promise -- they do not provide any sort of implementation to them. A type declaration is providing implementation, really. Who "owns" the declaration? The interface, or the class that implements the interface? Would you be able to say dim foo as SomeInterface.SomeStructure? There are just too many hard questions to be answered, and so interfaces cannot contain type declarations. That's not to say it's not a reasonable idea for the future, but it's certainly something that requires a lot more thought. Not something you just "throw in there" simply because you can. ;-)

1 Comments

Aaron-

Some languages permit the definition of constants within interfaces.

-Scott

Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.