Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Tue Jan 16, 2007 8:51 pm
A small snippet is better than a long explanation. All is in the title and the snippet :
I'm not sure if it's a good idea - maybe yes maybe no - just discuss about it.
Code: Select all
Structure PRODUCT
id.s
name.s
price.s
desc.s
EndStructure
Global NewList product.PRODUCT()
ForEach product()
With product()
Debug "id = " + \id
Debug "name = " + \name
Debug "price = " + \price
Debug "desc = " + \desc
Debug ""
EndWith
Next
ForEach product()
Debug "id = " + \id ; <--------- Syntax Error.
Debug "name = " + \name
Debug "price = " + \price
Debug "desc = " + \desc
Debug ""
Next
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Jan 16, 2007 8:54 pm
I once suggested this and people thought it was dreadful. But I think it's a good idea.
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Tue Jan 16, 2007 8:57 pm
hm... *shrug*
could be useful, but the leading backslash looks strange to me..
think i won't use it. copy/paste of the listname is sufficent ....
oh... and have a nice day.
AND51
Addict
Posts: 1040 Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:
Post
by AND51 » Tue Jan 16, 2007 9:22 pm
There is something similar in CGI - very useful.
$_ is the abbreviation for the currently used array in CGI/Perl.
I would appreciate this request, if there are no conflicts with other commands and if I still can access another linked list in that foreach/next loop.
Peaople like Kaeru Gaman, who don't like this, can still use myList()\id, etc within the foreach/next.
remi_meier
Enthusiast
Posts: 468 Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland
Post
by remi_meier » Tue Jan 16, 2007 9:53 pm
No way!
Code: Select all
NewList ll.Long()
NewList ll2.Long()
ForEach ll()
ForEach ll2()
\l = 4
Next
Next
Athlon64 3700+, 1024MB Ram, Radeon X1600
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Tue Jan 16, 2007 10:50 pm
Hi remi_meyer.
No Way ! Hmmmm, Why ?
Code: Select all
NewList ll.Long()
NewList ll2.Long()
ForEach ll()
\l = 1 ; same as ll()\l
ForEach ll2()
\l = 4 ; same as ll2()\l
Next
Next
ForEach ll()
ForEach ll2()
ll()\l = 4 ; if you need to use ll() in ll2()
Next
Next
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
remi_meier
Enthusiast
Posts: 468 Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland
Post
by remi_meier » Tue Jan 16, 2007 10:53 pm
That's just a mess...
Do you see the reason, why With-EndWith is not nestable?
Athlon64 3700+, 1024MB Ram, Radeon X1600
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Tue Jan 16, 2007 11:25 pm
Yes, i can easily imagine the mess for the pre-processor and for the pre-pre-processor (Fred/Freak).
I'm just discussing...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Kaeru Gaman
Addict
Posts: 4826 Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany
Post
by Kaeru Gaman » Tue Jan 16, 2007 11:33 pm
well... let me add the mess for the readability of your code...
oh... and have a nice day.
nco2k
Addict
Posts: 1344 Joined: Mon Sep 15, 2003 5:55 am
Post
by nco2k » Wed Jan 17, 2007 4:48 am
i think its a bad request.
if you want to use it that much, then simply write:
Code: Select all
ForEach List()
With List()
\Element = 0
EndWith
Next
i totally agree with remi.
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Hroudtwolf
Addict
Posts: 803 Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:
Post
by Hroudtwolf » Wed Jan 17, 2007 6:25 am
Code: Select all
Macro ForEachWith (_LIST_)
ForEach _LIST_ : With _LIST_
EndMacro
Macro NextWith
EndWith : Next
EndMacro
NewList test ()
AddElement (test ()):test()=1
AddElement (test ()):test()=2
AddElement (test ()):test()=3
AddElement (test ()):test()=4
ForEachWith (test ())
Debug test ()
NextWith
Joakim Christiansen
Addict
Posts: 2452 Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:
Post
by Joakim Christiansen » Mon Apr 16, 2007 6:33 pm
I agree that a With integrated in the ForEach loop would be nice.
Something like this:
Code: Select all
ForEach With Apples()
;bla bla
Next
The compiler should then see that With is used in the ForEach loop and end it at the Next command. I think this is the best way to do it? Fred?
I like logic, hence I dislike humans but love computers.
jear
User
Posts: 20 Joined: Sun Dec 28, 2003 12:27 am
Location: Ammerland
Post
by jear » Tue Apr 17, 2007 12:25 am
What is intended to be the higher abstraction level: ForEach or With?
Code: Select all
Structure Leute
Name.s
Vorname.s
Strasse.s
PLZ.s
Ort.s
EndStructure
NewList Leute.Leute()
With Leute()
ForEach
\PLZ = "26160"
Next
EndWith