InterfaceUnions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

InterfaceUnions

Post by MLK »

can be usefull to create a few aliasnames pointing to the same procedure

Code: Select all

Interface INTERFACE 
   InterfaceUnion
      Remove()
      Kill()
      Destroy()
      Delete()
   EndInterfaceUnion
EndInterface
btw:
maybe its the best to replace 'StructureUnion/EndStructureUnion' to 'Union/EndUnion' and make it possible to use this in interfaces.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

Yesss! :)
Athlon64 3700+, 1024MB Ram, Radeon X1600
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

I don't understand why you would want to have multiple aliases to the same function in a non-object oriented programming language.
Is it a good habit to enlarge language/library idiom without adding functionality?
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I have to admit than i don't see the use of having aliases pointing to the same function. If someone can clarify this, it should not be a problem to implement it.
Last edited by Fred on Wed Sep 28, 2005 2:14 pm, edited 1 time in total.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

-1

Many PBers are struggling to make sense of Interfaces as it is, without adding further complexity.
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

i have to admit, that im not still sure if using of unions would be better than using none, but have a (maybe?) better structured code for some bytes more. not to be sure means, im not sure, not im sure i dont like it anymore :-)

the idea was to write:

Code: Select all

Interface iGUI 
   ;ListIconGadget
   PrependRow(Text$)
   InsertRow(Row.l, Text$)
   AppendRow(Text$)
   
   ;PanelGadget
   PrependPanel(Text$)
   InsertPanel(Pos.l, Text$)
   AppendPanel(Text$)
   
   ;...
EndInterface
as:

Code: Select all

Interface iGUI
   InterfaceUnion
      PrependRow(Text$)
      PrependPanel(Text$)
   EndInterfaceUnion
   InterfaceUnion
      InsertRow(Row.l, Text$)
      InsertPanel(Pos.l, Text$)
   EndInterfaceUnion
   InterfaceUnion
      AppendRow(Text$)
      AppendPanel(Text$)
   EndInterfaceUnion
EndInterface
by using IsGadget(), IsWindow() ..... and GetGadgetType() [please implement in PB!] there is something nice possible..
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Why not this?

Code: Select all

Interface iGUI
   Prepend(Text$)
   Insert(Item, Text$)
   Append(Text$)
EndInterface    

Interface iRowGUI
   PrependRow(Text$)
   InsertRow(Row.l, Text$)
   AppendRow(Text$)
EndInterface    

Interface iPanelGUI
   PrependPanel(Text$)
   InsertPanel(Pos.l, Text$)
   AppendPanel(Text$)
EndInterface    

MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

because i like it easy
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Nah.
BERESHEIT
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

How is this not easy?

Underneath you have a single vTable, and you just point the appropriate Interface at it?

It uses less lines of code, and it is clearer why different names exist.
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

plz - stop discussion about everything not related to the suggestion of InterfaceUnions - thx
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

MLK wrote:i have to admit, that im not still sure if using of unions would be better than using none, but have a (maybe?) better structured code for some bytes more. not to be sure means, im not sure, not im sure i dont like it anymore :-)

the idea was to write:

Code: Select all

Interface iGUI 
   ;ListIconGadget
   PrependRow(Text$)
   InsertRow(Row.l, Text$)
   AppendRow(Text$)
   
   ;PanelGadget
   PrependPanel(Text$)
   InsertPanel(Pos.l, Text$)
   AppendPanel(Text$)
   
   ;...
EndInterface
This is a typical case for the "extends" keyword.
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sorry but i'm not convinced, it's sounds like a 'design flaw' to me. If you want to detect the gadget type with GadgetType() (assume it exists), the best is to define several interfaces for eachtype (which can eventually share the same VT, it's not a problem).
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

WHY is everybody giving me tips to solve an unexistent problem?

i know what im coding and have no troubles with it. i know about the possibility to extend an interface with ONE other interface, indirect with more - thats how i started. i know how to design interfaces for each gadget individual - thats how i started. i know how to get the gadgettype. i know how to share a vTable.

THX for helping me in that difficult situation.


next time please keep it easy with -1/+1 or however u like to response to an feature request, a suggest, an idea to extend the language.
dell_jockey
Enthusiast
Enthusiast
Posts: 767
Joined: Sat Jan 24, 2004 6:56 pm

Post by dell_jockey »

MLK wrote:WHY is everybody giving me tips to solve an unexistent problem?
Perhaps your real problem wasn't defined clearly enough, so that all reactions/tips were of no help to you?

Whatever the cause, there's no need to react this touchy.
This is one of the very few forums left, where information exchange most of the time takes place in a very polite and considerate manner. I lurk the German board as well, and I know that quite often the tone is a bit harsher over there. Please, let's not start with that on this forum... Thanks!
cheers,
dell_jockey
________
http://blog.forex-trading-ideas.com
Post Reply