BlitzMax overview docs

BlitzMax Forums/BlitzMax Module Tweaks/BlitzMax overview docs

markcw(Posted 2010) [#1]
This is an update to BlitzMax overview.bbdoc (from v 1.41).

I basically fixed some broken links and reformatted the example code. I also found that makedocs adds <p> inside <pre> tags on html files so that's why I've added &nbsp; on every empty line inside <pre>... Edit: I've now added my own ending to the "Intro to OOP" tutorial rather than leave it saying "Stay tuned for part 2".

The files are zipped and posted below along with the patch.
blitzmax-overview-doc.zip (expired)

Last edit: 17 Aug 2010

BlitzMax overview.diff


BlitzMax overview.bbdoc


upperstream.bmx



markcw(Posted 2010) [#2]
It would be great to add new sections to the OO tut for Abstract classes and Polymorphism... I would do it but I don't really know enough about these topics so I'd just be blindly copying stuff from other sites.

Anyone want to write a tut for even one of these topics?! We lesser folks could really use a good Bmx explanation.

Edit: might as well post some links.
http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming
http://en.wikipedia.org/wiki/Virtual_class
http://en.wikipedia.org/wiki/Virtual_function
http://en.wikipedia.org/wiki/Class_(computer_science)#Categories_of_classes
http://en.wikipedia.org/wiki/Abstract_type


Jesse(Posted 2010) [#3]
there are two in the tutorial section on polymorphism:
http://www.blitzbasic.com/Community/posts.php?topic=78860
http://www.blitzbasic.com/Community/posts.php?topic=59233


markcw(Posted 2010) [#4]
Thanks Jesse. I've seen the first one and it's a mess but yeah, John J's tut covers Polymorphism nicely so I'll use that but he doesn't go into using Abstract properly.

Any links for that? ;)


Jesse(Posted 2010) [#5]
I don't know any links for it. I'll try to explain it:
abstract serves two purpose, one is to prevents a type from being used with out the extended type, weather "Abstract" is used in the declaration of a Function, Method or a type. For example you can declare a type as abstract like this:
Type base Abstract
  field x:float

  Function Foo()
  .
  .
  End Function
  
  Method mymethod()
     x = 3
  End Method
end type
this will prevent an instance of base type to be created.
But, it can be create like this:
'                  note there is no Function or Method declared in this type.
Type childtype Extends base 
End Type

local mytype:childType = new childtype

and is perfectly valid.

The other purpose is when "abstract is used on a Function and/or Method. If a type has a function or a method that contain abstract, the type signals the compiler that the extended type "must" have the definition of the function or the method and must have the same parameters and that the base type can never be instantiated by itself. If there is no definition of the abstract function or method in the extended type, the compiler will produce an error.

Type base
   Field x:int

   Method Update(x:int) abstract ' template for extended types
End Type

Type mytype Extends base
    Method Update(x:int) ' required because the base has a method of same name as abstract.
      self.x = x
    End Method
End Type


there can not be an abstract method or function in the extended type.

I hope this is clear as I don't write good tutorials. I wrote this in hope you can understand it and write your own version of it.


markcw(Posted 2010) [#6]
That's pretty good. Thanks very much. I should be able to cobble something decent together now.


markcw(Posted 2010) [#7]
Ok, I forgot the "User defined types" section covers these topics already so I've just added a link to it at the end of "Intro to OOP" instead of adding new parts myself.


markcw(Posted 2010) [#8]
Just changed my mind again and added a 'proper' ending to "Intro to OOP" as even along with "User defined types" there are still things missing.

Hopefully I haven't made a mistake.

Edit: ok, I fixed a mistake on the last line. I didn't know about final.