Author Topic: Functions in Types?  (Read 20551 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10726
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Functions in Types?
« on: 2010-Apr-30 »
Uhm, well.
I don't like it. I won't support it much, but you asked for it until my ears were bleeding.

First, the TYPEs should soon be able to have functions as members as well as a "self" variable pointing to it self.
Code: (glbasic) [Select]
TYPE Tvec
   x;y;z
   FUNCTION null:
      self.x = 0; self.y=0; self.z=0
   ENDFUNCTION

   FUNCTION add: v AS Tvec
     INC self.x, v.x
     INC self.y, v.y
     INC self.z, v.z
   ENDFUNCTION
ENDTYPE

LOCAL vec AS Tvec, vec2 AS Tvec

vec.null()
vec.x=50
vec2.x = 100
vec.add(vec2)

Also, I think about including the AS standard types: double, float, int, short, char.

It will be a version 8.x upgrade. We have 7.x for about a year now - time to increase the version number :P


Here's a beta patch of the GPC you need. If you're uncertain how to install it, don't!
Do backup before you replace it. I've built some old projects ok with it, but there was times when it made really nasty and hard to identify errors. Be warned. Don't use it for an AppStore release unless you really thoroughly tested the output.
http://www.glbasic.com/beta/platform.rar
« Last Edit: 2010-May-04 by Kitty Hello »

Offline Quentin

  • Prof. Inline
  • *****
  • Posts: 915
    • View Profile
Re: Functions in Types?
« Reply #1 on: 2010-Apr-30 »
lol

GREAT!

but you'll regret it, I'm sure.
don't forget to offer PRIVATE, PUBLIC for TYPE members :)))

Offline gregbug

  • Mr. Drawsprite
  • **
  • Posts: 54
    • View Profile
Re: Functions in Types?
« Reply #2 on: 2010-Apr-30 »
yeeeaaahhh!!!!
thanks!
Ciao Ciao,
 Gianluca. (l'Aquila tornerà a volare alta nel cielo!!!!)

Offline Scott_AW

  • Mr. Polyvector
  • ***
  • Posts: 214
    • View Profile
    • SAW Game Design
Re: Functions in Types?
« Reply #3 on: 2010-Apr-30 »
Functions in types?  Interesting...

I like that part about standard types, I was kind of missing those.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2651
    • View Profile
Re: Functions in Types?
« Reply #4 on: 2010-Apr-30 »
Not keen on functions in types, start of the slippery slope down OOP  :puke: ... but I do know folk want it.

Quote
double, float, int, short, char

Now this is something I would like to see, its a definite step to towards easy C library compatibility, which would open a whole world of possibilities for me.

Congrats Gernot, nothing easy to do in that post, much appreciated!  :enc:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline doimus

  • Dr. Type
  • ****
  • Posts: 284
    • View Profile
Re: Functions in Types?
« Reply #5 on: 2010-Apr-30 »
 :booze: :enc:

[attachment deleted by admin]

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5034
  • O Rly?
    • View Profile
Re: Functions in Types?
« Reply #6 on: 2010-May-01 »
 <3 I love you!  <3
  :happy:  :nw:

On your post you forgot the white flag gernot ;) -> :giveup:


Thank you so much!

Edit:

You implement this feature on your GLBasic version, and it work?!
« Last Edit: 2010-May-01 by Schranz0r »
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Kuron

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
Re: Functions in Types?
« Reply #7 on: 2010-May-01 »
Quote
On your post your forgot the white flag gernot
Based on Gernot's feelings about the new feature, it is more like  >:D

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5034
  • O Rly?
    • View Profile
Re: Functions in Types?
« Reply #8 on: 2010-May-01 »
 :D also a good smily :D
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline aonyn

  • Mr. Polyvector
  • ***
  • Posts: 136
    • View Profile
Re: Functions in Types?
« Reply #9 on: 2010-May-01 »
Ah, nice Gernot, that will allow more OOP style with methods.
Please though, don't allow OOP to take over to the point it is required.
OOP is great when it can be used as a tool as needed.

Thanks.

@ Schranz0r - I just want to mention, I love your avatar, it makes me smile everytime I see one of your posts.  =D
Did you make that character?

regards,
Dave
For by grace are ye saved through faith, and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. -Ephesians 2:8-9

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5034
  • O Rly?
    • View Profile
Re: Functions in Types?
« Reply #10 on: 2010-May-01 »
@ Schranz0r - I just want to mention, I love your avatar, it makes me smile everytime I see one of your posts.  =D
Did you make that character?

No i find that picture in the WWW :)
Thats my ABSOLUT FAVORIT Avatar :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline aonyn

  • Mr. Polyvector
  • ***
  • Posts: 136
    • View Profile
Re: Functions in Types?
« Reply #11 on: 2010-May-02 »
Haha, just smiled again  =D
Definately one of the best avatars I have ever seen.

regards,
Dave
For by grace are ye saved through faith, and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. -Ephesians 2:8-9

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5034
  • O Rly?
    • View Profile
Re: Functions in Types?
« Reply #12 on: 2010-May-02 »
 :happy: Thank you  :enc:
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Kuron

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
Re: Functions in Types?
« Reply #13 on: 2010-May-02 »
I am rather partial to this ostrich head:


Offline aonyn

  • Mr. Polyvector
  • ***
  • Posts: 136
    • View Profile
Re: Functions in Types?
« Reply #14 on: 2010-May-02 »
YIKES!!!!  :blink:
For by grace are ye saved through faith, and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. -Ephesians 2:8-9