[Implemented] LinkedLists inside Structures

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

@ Hroudtwolf: Why would the syntax change?!
Was this a rhetorical query?
I think, it is obvious that this act would make syntaxchanges necessary.

Code: Select all

   Structure bla
      NewList Bla.l () ;<--- no case of pb syntax
   EndStructure
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Hroudtwolf wrote:I disagree.
A dynamic linkedlist lib would be more important.
Surely that is a request for a different feature and not a reason for arguing against this request?
Dare2 cut down to size
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

I buyed a copy of PB and therefore I (as user) disagree each feature-request if I think it wheren't right for the development of purebasic.
Please, accept my opinion.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Hroudtwolf wrote:Please, accept my opinion.
I do.

Accept mine? :D

Then neither of us can argue against the other (by your logic) and so you need to start a new feature request. :)
Dare2 cut down to size
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

No.
I disagreed your feature-request and proposed another one of the same relation, what would be better (in my opinion).
This is a discussion-forum. If you don't want discussions, your'e not right here. ;-)
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Hroudtwolf wrote:No.
I disagreed your feature-request and proposed another one of the same relation, what would be better (in my opinion).
This is a discussion-forum. If you don't want discussions, your'e not right here. ;-)
:)

So you can discuss and argue against a post.
But I can't discuss and argue against your post? :shock:

lol. (Just teasing)
Dare2 cut down to size
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

*shaking the head*
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:)

* shakes hands *
Dare2 cut down to size
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

*slapps friendly his back* ^^
ZeHa
User
User
Posts: 38
Joined: Sun Apr 24, 2005 11:39 pm

Post by ZeHa »

Hroudtwolf wrote:
@ Hroudtwolf: Why would the syntax change?!
Was this a rhetorical query?
I think, it is obvious that this act would make syntaxchanges necessary.

Code: Select all

   Structure bla
      NewList Bla.l () ;<--- no case of pb syntax
   EndStructure
LOL, of course that's something new in syntax, but it's not a real "syntax change", it's a "syntax extension". The old syntax isn't affected, so where's the problem?

Oh, I see:
Hroudtwolf wrote:That could be a new source of bugs. *paranoia*
Well, every new feature, no matter if syntax changing / extending or bringing up new library functions can produce bugs.
Hroudtwolf wrote:I buyed a copy of PB and therefore I (as user) disagree each feature-request if I think it wheren't right for the development of purebasic.
If you're afraid of every possible bug in new features, I actually wonder what your definition of "development of PureBasic" is.


In my opinion, if PureBasic is still lacking some important features that are available in many other languages, then there should be hope that it will be also available in PureBasic one day. That doesn't mean everything has to be copied, but having a list inside a structure is something so essential and I'm actually surprised that it doesn't work in PureBasic.

Also, "NewList" inside a structure would be the only real "change", because the list is merely a pointer, so everything else should go pretty analoguous:

Code: Select all

Structure Player
    NewList weapons.Weapon()
EndStructure

p.Player
someWeapon.Weapon

AddElement(p\weapons())          ; <-- nothing really new here
p\weapons() = someWeapon          ; <-- nothing really new here
FirstElement(p\weapons())          ; <-- nothing really new here
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

You'll can't change my opinion. Even if you comment each of my posts.
I explained my opinion it already.

Code: Select all

Structure Player
    NewList weapons.Weapon()
EndStructure
Please show me a modern language, where such funny one is possible inside a declaration of a structure.
ZeHa
User
User
Posts: 38
Joined: Sun Apr 24, 2005 11:39 pm

Post by ZeHa »

C, C++, D, Java, Python, C#, to name a few...
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

@ZeHa: Hroudtwolf's alternate feature request seems to only duplicate what you've requested. Unfortunately if implemented, his has all the syntax problems that he would be *paranoid* about. For instance, in his code sample you can't tell when a variable is referencing a list or not, there are no ()'s being used with any of the list functions. It also seems to require the "NewList" function to try and figure out its own parameters (they are on the opposite side of the equation in syntax).

Code: Select all

*List.tMyData = NewList
AddElement (*List)
*List\sName = "Frédéric Laboureur"
*List\sEmail = "support [at] purebasic.com"
; With dynamic instanced LinkedList, you could do that.
*List\Properties = NewList
AddElement (*List\Properties)
*List\Properties\sName = "talent"
*List\Properties\sAssoc = "Developed a realy cool programming language."
Your feature request does seem to be the more straight forward one, and it seems to include everything that he wanted (in his own feature request). As you stated it doesn't require any strange syntax, it uses ()'s with the variables that point to lists. There are a few quirks left though. I think that using "NewList" in a structure is informative but awkward. It could be simplified by leaving it off, since the ()'s indicate that the variable is a list. Static arrays in structures are similiar, they don't use "Dim" and you still know that they're arrays. What do you think?

Code: Select all

Structure Player
    weapons.Weapon()    ;This is the list()
    inventory.Weapon[5] ;This is a static array[]
EndStructure
In the example you gave, of how such a feature may be used in code, there is another feature that doesn't currently exist. It is the copying of a structured element. I've marked it below.

Code: Select all

Structure Player
    NewList weapons.Weapon()
EndStructure

p.Player
someWeapon.Weapon

AddElement(p\weapons())          
p\weapons() = someWeapon       ; <-- This is new
FirstElement(p\weapons())         
The ability to assign a structured element to a list or an array has been a hoped-for feature for quite a while.

If your feature request is ever implemented it would allow LinkedLists in structured arrays also. I see it as a big plus in simplifying all of the workarounds that are currently being used for the same purpose. I don't see any cons to doing it (besides the programming team's time and effort). :wink:
ZeHa
User
User
Posts: 38
Joined: Sun Apr 24, 2005 11:39 pm

Post by ZeHa »

Well, "NewList" in a structure might indeed seem a little awkward, but on the other hand, it's absolute clear, and it follows PB's syntax style. Also, there are some OOP-precompilers around which would count "()" as a function, not as a list. If ever PB should get native OOP-support (which probably won't happen, but never say never), then it would be very bad to have "()" as a list, and we'd have big syntax changes again (which someone could get paranoid about (including me :D )).

So, NewList is outside structures, inside functions, so it should also be inside structures in my opinion.
I don't see any cons to doing it (besides the programming team's time and effort)
Yes, me too... it's absolutely essential, and Hroudtwolf said he "explained" his opinion, but honestly I can't find anything that looks like an explanation...
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Yes, me too... it's absolutely essential, and Hroudtwolf said he "explained" his opinion, but honestly I can't find anything that looks like an explanation...
Whats up?
Sorry. Do you need eyeglasses? ^^
Post Reply