[Implemented] multi var declaration

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

[Implemented] multi var declaration

Post by MLK »

Code: Select all

x,y,z=1
;x=1
;y=1
;z=1

Global x=1,y,z=2 ;this option would be nice too
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

now *this* one, I miss too..
I'm sure it would be a nice addition to PB.. :)

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: multi var declaration

Post by GPI »

Code: Select all

x,y,z=1
;x=1
;y=1
;z=1
Hmm, i don't think, that this would be a good idea...

[/code]
Global x=1,y,z=2 ;this option would be nice too
[/code]

But this would be nice...
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Re: multi var declaration

Post by freedimension »

MLK wrote:

Code: Select all

x,y,z=1
;x=1
;y=1
;z=1
Never seen this one. I like the way C handles this:

Code: Select all

x=y=z=1
As for the second: Yes, that would be very handy.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Jippee, another feature for us lazy guys :D

The "x=y=z=1" is not basic styl though. You usually don't have multiple
'=' in one line.

You have my vote for the Global thing.

Timo
quidquid Latine dictum sit altum videtur
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: multi var declaration

Post by GPI »

Code: Select all

x=y=z=1
This is not allowed in Basic. The first "=" is intrepreated as a "Set X to" and the next two are compares: x=z and (x=z)=1.

Your Example will only work, when "Set a Variable" and "is equal" have two diffent chars.
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

last night i had a dream:

Code: Select all

Globals
    x.l=4
    y.w
    z.f=1.23
EndGlobals
same for declares..

dont want to open a new topic. but what do you think about this, instead of:

Code: Select all

global this
global that
global this, and, that
this=1
that=2
Saboteur
Enthusiast
Enthusiast
Posts: 272
Joined: Fri Apr 25, 2003 7:09 pm
Location: (Madrid) Spain
Contact:

Post by Saboteur »

MLK wrote:last night i had a dream:

Code: Select all

Globals
    x.l=4
    y.w
    z.f=1.23
EndGlobals
I like it... ;)
[:: PB Registered ::]

Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I do understand the request for this:

Global a=5, b=6

But the other thing just doesn't make sense to me.
Why not put it in one line?

btw, do you also want to add Shareds/EndShareds, Protecteds/EndProtecteds, Statics/EndStatics??
That's a lot of unneded commands imho.

TImo
quidquid Latine dictum sit altum videtur
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

freak wrote:Why not put it in one line?
because, at larger codes, there are sometimes many globals. that would result in a long line and isnt very clearly arranged. and no - i dont request that for everything, only for globals and maybe for declares.
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

MLK wrote:
freak wrote:Why not put it in one line?
because, at larger codes, there are sometimes many globals. that would result in a long line and isnt very clearly arranged. and no - i dont request that for everything, only for globals and maybe for declares.
Ehhhh - don't get this... You don't need to have ALL variables on one line, do you?

You can write,

Code: Select all

Global a, b=1, c, d
Global e=6, f, g
Global h, i , j
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

i know..
techjunkie
Addict
Addict
Posts: 1126
Joined: Wed Oct 15, 2003 12:40 am
Location: Sweden
Contact:

Post by techjunkie »

MLK wrote:i know..
so, what's the problem?!?! :?:
Image
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

its no problem. its a request.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

It looks neater.

Code: Select all

StartGlobal
   var.l
   etc.l
EndGlobal
Adds nothing to the compiled prog either.

And doesn't mean can't still use

Code: Select all

Global var.l, etc.l

But before all that:
  .. NOT
  .. SGN
  .. structureComplete=otherStructureComplete
  .. Fixed length strings capable of containing an embedded binary 0
  .. Double Precision
  .. Logical operators acting logically in expressions.

And etc.
Post Reply