Results of assignments

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:

Results of assignments

Post by Hroudtwolf »

Hi,

My little wish is, to have the possibilities in PB for receiving results of assignments.

In example:

Code: Select all

if let ( MyVariable = 100 ) = 100 : CallMyFunction () : endif
(Checking if MyVariable has the value 100.)

... or ...

Code: Select all

resultOfTheAssignment = let ( MyVariable = 100 )
(resultOfTheAssignment receives the value of MyVariable.)

Similar to PHP:

Code: Select all

	if ( ( $result = 123 ) == 123 ) echo 1;
	if ( ( $result = 123 ) == 321 ) echo 2; // No equivalence
Best regard

Wolf
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I was actually thinking this myself. I think what we're looking for is the ability to evaluate an expression before the 'If'.

I like your idea but is there a solution that does not require the 'Let' keyword?
Last edited by Mistrel on Tue Nov 04, 2008 1:39 am, edited 1 time in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

I know that this is possible in C because the Assignor and the Comparator are differerent symbols, "=" and "==".

... but I never really discovered the deeper usefulness of this feature....
oh... and have a nice day.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post by Little John »

Kaeru Gaman wrote:... but I never really discovered the deeper usefulness of this feature....
The deeper usefulness of this feature is that it makes the code harder to read. :mrgreen:

Regards, Little John
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Little John wrote:
Kaeru Gaman wrote:... but I never really discovered the deeper usefulness of this feature....
The deeper usefulness of this feature is that it makes the code harder to read. :mrgreen:
Right!, which converts it in less than a "useful-less" feature. :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Kaeru Gaman wrote:I know that this is possible in C because the Assignor and the Comparator are differerent symbols, "=" and "==".

... but I never really discovered the deeper usefulness of this feature....
I not daft but what exactly is the usefulness of this feature? From the examples show I can't see it, a few words of enlightenment from the sages here would go a long way in clearing this up for me. :wink:

I am aware of these aspects in the C language but have not used them.
Post Reply