Assignment = or := ?

Assignment = or := ?

Postby Otto » Mon Jan 18, 2010 10:01 am

I have noticed that in FIVEWIN the assign is done with = and := .

Could someone explain when to use = and when := .

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: Assignment = or := ?

Postby Enrico Maria Giordano » Mon Jan 18, 2010 11:12 am

= is the normal assignment operator while := in the inline version of the same operator. As an example:

REDEFINE BUTTON ACTION x = 1 // wrong!

REDEFINE BUTTON ACTION x := 1 // ok!

x = 1 // ok!
x := 1 // ok! It's the same
a = b = 1 // means a = .T. if b = 1 or .F. if b != 1
a = b := 1 // means a = 1 and b = 1
a := b := 1 // the same as above

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8528
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Assignment = or := ?

Postby James Bott » Mon Jan 18, 2010 7:02 pm

Otto,

If you have the Clipper help file, there are good descriptions in there.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Assignment = or := ?

Postby Otto » Mon Jan 18, 2010 9:29 pm

Hello Enrico, hello James,

Thank you for explaining to me.
For example in TRBGroup-class assignments are made with := in TBtnBmp classe with =
( VB6 style which I don’t like). I thought that there is maybe a difference which I am not aware of.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: Assignment = or := ?

Postby Enrico Maria Giordano » Mon Jan 18, 2010 9:58 pm

= is not a VB assignment style at all. It's the most widely used token for the assignment operator. And it's good style in xBase too. I can't see why to use the inline assignment operator in a statement like

Code: Select all  Expand view
a := 1


and I don't like it for sure.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8528
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Assignment = or := ?

Postby sambomb » Tue Jan 19, 2010 10:31 am

To be sure, use := always 8)
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
User avatar
sambomb
 
Posts: 385
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: Assignment = or := ?

Postby Enrico Maria Giordano » Tue Jan 19, 2010 10:39 am

Ok, so to be sure use always + because * is too complicated. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8528
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Assignment = or := ?

Postby Otto » Tue Jan 19, 2010 11:19 am

Hello Enrico,
Fivewin classes are my reference for good programming style. As I see that for the same assignment in different classes = and := are used I asked which is the right way.
I personally prefer :=. Why context determining which is meant.
Thanks again for your help.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6255
Joined: Fri Oct 07, 2005 7:07 pm

Re: Assignment = or := ?

Postby Antonio Linares » Tue Jan 19, 2010 1:41 pm

Otto,

We do prefer to use "=" unless ":=" (inline assignment) is required.

Anyhow, both ways are valid, though "=" is simpler :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41858
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests