Prototype with LinkedList

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

Prototype with LinkedList

Post by Leonhard »

Why can I not use LinkedList with prototypes?

I have build a example:

Code: Select all

Prototype.l Callback(nValue.l)
Global NewList e_Event_Call.Callback()

Procedure Event1(nValue.l)
  Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
  Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
  Debug "CALL-3: "+Str(nValue)
EndProcedure

AddElement(e_Event_Call()) : e_Event_Call() = @Event1()
AddElement(e_Event_Call()) : e_Event_Call() = @Event2()
AddElement(e_Event_Call()) : e_Event_Call() = @Event3()

Debug e_Event_Call()(43)
Debug e_Event_Call()(534)
Debug e_Event_Call()(955)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The syntax is ugly :)
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

Post by Leonhard »

other ideas?
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

Fred wrote:The syntax is ugly :)
the linkedlist syntax itself is ugly :twisted:
the same goes for arrays :twisted: :twisted:

Dri
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

huh, whats ugly about the linkedlist and array syntax?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Leonhard wrote:other ideas?
Just use a structure...

Code: Select all

Prototype.l Callback(nValue.l)

Structure CallbackStruct
  Call.Callback
EndStructure

Global NewList e_Event_Call.CallbackStruct()

Procedure Event1(nValue.l)
  Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
  Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
  Debug "CALL-3: "+Str(nValue)
EndProcedure

AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event1()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event2()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event3()

Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
quidquid Latine dictum sit altum videtur
User avatar
IceSoft
Addict
Addict
Posts: 1683
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

freak wrote:
Leonhard wrote:other ideas?
Just use a structure...

Code: Select all

Prototype.l Callback(nValue.l)

Structure CallbackStruct
  Call.Callback
EndStructure

Global NewList e_Event_Call.CallbackStruct()

Procedure Event1(nValue.l)
  Debug "CALL-1: "+Str(nValue)
EndProcedure
Procedure Event2(nValue.l)
  Debug "CALL-2: "+Str(nValue)
EndProcedure
Procedure Event3(nValue.l)
  Debug "CALL-3: "+Str(nValue)
EndProcedure

AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event1()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event2()
AddElement(e_Event_Call()) : e_Event_Call()\Call = @Event3()

Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
Hippiaiho!
@freak,
You use OOP ideas. Shame on you ;-)

Please remove:

Code: Select all

Debug e_Event_Call()\Call(43)
Debug e_Event_Call()\Call(534)
Debug e_Event_Call()\Call(955)
with:

Code: Select all

ForEach e_Event_Call()
  Debug e_Event_Call()\Call(534) 
Next
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

DoubleDutch wrote:huh, whats ugly about the linkedlist and array syntax?
i can't have an array of lists, or a list of arrays etc...

Dri
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Those would be useful I agree.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply