Page 4 of 4

Posted: Sun Jan 13, 2008 8:11 pm
by ZeHa
If you're using NewList globally or in a function, it's generally nothing more than a simple pointer. You have a pointer to a list now, and you can use several functions like AddElement() and so on to work with that list.

If NewList would be possible inside a Structure, how would it be different? There would be no memory management madness, as there would be simply a pointer to store. Nothing too fancy, I think. If you're using C++ or Java and you're using a LinkedList inside a class, it's just a reference to the list, not the whole list elements saved inside the structure / class.
But as you say, there are many workarounds to do that, and some of these workarounds are really really elegant.
So then to implement that request would be a good way to complicate PB language unfoundedly, imo.
I don't think so. A list can be in global scope or in function scope. Why not also in structured scope? I don't see why this would make PB more complicated, in fact, it would only help to make it a better language. The workarounds are not elegant at all, since you always have to do weird stuff which is possible as a native thing in other languages.

You can also regard functions as an unnecessary feature, since we could use Gosub and Return as a workaround instead. And why do we have With and EndWith? We can also just do it the normal way. Why do we have Select and EndSelect? It can be done with several Ifs.
And why LinkedLists? We could write them on our own!

In my opinion, there are tons of cases where you would love to have some function like that. It's totally normal for other languages, and it's basically just a pointer, nothing special. It's just not possible to use it that way because of some syntactic stuff. If AddElement() could accept a pointer and if @listName() would return the address of the list (or the first element), it would be already possible.

Posted: Sun Jan 13, 2008 9:46 pm
by Franky
Ok, my 2 cents:

I think

Code: Select all

   Structure blabla
        wert.l ;This is a variable
        mydata[5];This is an array
        MyList.l() ;This is a Linkedlist
  Endstructure 
is a good idea.

I already wrote my own Macros to have this feature. But it would be handy to have it as normal PB-Stuff, because for the moment to get the Used Macros I have to call a selfmade Init-Macro for Each ListType (Type of the entries, I mean) I´m using.

I disagree to Hroudtwolfs idea indirectly.
This Dynamic stuff, he´s wishing is not bad, but I think PB should keep the LinkedlistSyntax for those funktions. Pointers are a little abstract for that. I mean, you don´t the, that it´s a Linkedlist.

It would be nice to have a syntax nearly like the one I created, but without the use of explaining the LLs Type. Something like "Virtual New List" would be nice in this case.

Could have been better at the beginning of PB, when Fred had used {} as Linkedlist-Breaks and Array-Breaks. Or as Procedure-Breaks, as one of the options. This way it had been clearly easy to see, if it´s a Linkedlist or a procedure. But it´s a little to late to change that, so no problem, it´s ok, that way, too.

Posted: Sun Jan 13, 2008 10:41 pm
by ZeHa
I disagree because of two reasons ;)

1) NewList is an established PB keyword and it wouldn't be logical if some lists have to be made with NewList and some without.

2) There are quite a few OOP-precompilers around, which is a good thing, and if you declare lists only with "()", precompilers wouldn't have a chance to declare methods like that.

I know the second reason is not related to the official language, but I think the first reason should actually be strong enough ;) I know, arrays are also declared differently here (with "[]"), but that's also pretty inconsistent.

Posted: Mon Jan 14, 2008 1:01 am
by Dare
The syntax discussion is secondary. The capability is what counts. If the team decided to do this I am sure they would come up with a good syntax. :)

Memory management issues are big, but then so are a lot of other things in compilers. So let the developers have the headaches of baking it and let the users get and eat the cake. :D

A lot of people mention cross-platform as being PureBasic's big strength. This is a strength, but ..

.. the real strength is that PureBasic makes itself easy to use whilst still allowing advanced stuff to be done.

It possible for dabblers and dullards like me to get some reasonable stuff out. It is possible for others to do pretty advanced stuff that would give me a headache.

So adding features like this is a good thing for PureBasic to do. It adds value and marketability to the PureBasic product. It makes it attractive to others like me and certainly won't make it unattractive to others. After all, you can choose to not use something that exists but you cannot choose to use something that isn't there.

:mrgreen:

Posted: Mon Jan 14, 2008 1:28 am
by JCV
well said. :D

Posted: Sun Apr 26, 2009 9:08 pm
by milan1612
Just spent 2 hours to bypass this limitation, that's really annoying :x. Fred or Freak,
would you please clarify wether or not you'll be adding this to Purebasic? Is it somehow
planned or at least on the todo list? I think it's at least one of the most requested
feature, if not the most. I really hate having to directly mess with memory
for such basic tasks - in a Basic language! Not ment to be rude but...:P

Posted: Sun Apr 26, 2009 9:30 pm
by freak
This is definitely planned for the near future. I cannot tell you an exact version though, as implementing this is entirely up to Fred.

Posted: Sun Apr 26, 2009 9:47 pm
by milan1612
freak wrote:This is definitely planned for the near future. I cannot tell you an exact version though, as implementing this is entirely up to Fred.
Thanks for the clarification, that's great to hear! :)

Posted: Mon Jul 06, 2009 10:54 pm
by c4s
freak wrote:This is definitely planned for the near future. I cannot tell you an exact version though, as implementing this is entirely up to Fred.
Soon we have a new release, right?
So I'm waiting (and hoping) :wink:

edit:
Oh I just realized that freaks and milans posts were made in 2009 (thought
2008) - Yeah.. so it's even more possible!

Posted: Tue Jul 07, 2009 4:19 am
by cas
c4s wrote:So I'm waiting (and hoping) :wink:
Me too :)

Posted: Tue Jul 07, 2009 10:14 pm
by Matt
I needed this in a project the other day, couldn't figure out how to do it in the help file. Went on the forums and found out it couldn't be done. :cry:

So I used a nasty method where two linked lists are joined together with an ID, like:

Code: Select all

Structure Categories
  name.s
  number.l
EndStructure

Structure Choices
  name.s
  pixelx.l
  pixely.l
  categoryNumber.l
  number.l
EndStructure
:oops: