Structure-EndStructure high improvement

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Structure-EndStructure high improvement

Post by Psychophanta »

Is there any reason to not to allow Structures which contain function pointers to be called (just like in Interfaces) and also standard fields?
Ilustrative example:

Code: Select all

Structure one
  one01.l
  one02.l()
  one03.b(v.c)
  one04()
  *one05.s
  one06.l[12]
  one07.b(a.f,b.f)
  one08.b(inputvar.l)
  one09.c
  one10.point
  one11.q(var1.q,in.l)
EndStructure
;
*p=?label
v.one=@*p
;
Debug v\one07(23.12,14.6478437)
v\one09='r'
;
DataSection
label:
Data.l 0,@f_one02(),@f_one03(),@f_one04()
Data$ ""
Data.l 0,0,0,0,0,0,0,0,0,0,0,0
Data.l @f_one07(),@f_one08()
Data.c 0
Data.l 0,0
Data.l @f_one11()
As can see, this implicates another benefit lateral effect: to abolish the existence of Interface-EndInterface block, because it would be nonsense.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Well first there is no way on Earth that your proposed use of a structure should ever render interfaces obselete because they have a very definite useage; namely COM, and as such are based upon a virtual table of pointers etc. An interface has an extra layer of 'indirection' as required by the COM standard and so they are going nowhere! :wink:

As for your suggestion, well, can we not already do this through prototypes? You can declare a structure field to be a prototyped type and this will give you your required functionality!

Code: Select all

Prototype test(a.s)

Structure myStruc
  a.test
  b.l
EndStructure

Procedure Heyho(name.s)
  Debug "Hello "+name+"!"
EndProcedure

x.MyStruc\a = @Heyho()

x\a("Sam")
I may look like a mule, but I'm not a complete ass.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Yes, i already thought on Prototypes, but i think that if structures allowed what i explained then things would be much more sorten and clear...
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply