Re: [fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-04-02 Thread Marc Weustink

On 28-3-2013 17:52, Jonas Maebe wrote:



+= does *not* prevent re-evaluating the left side. It is internally
translated to x:=x+y and then evaluated like normal. So if x
contains a function call with side effects, these side effects are still
triggered twice.


Is evaluated as x := x + y or as x := x + (y)
(where Y can be any expression)

I usually tanslate C code like the first, but recently found out that is 
should be done like the last.


Marc

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-04-02 Thread Jonas Maebe


On 02 Apr 2013, at 11:11, Marc Weustink wrote:


On 28-3-2013 17:52, Jonas Maebe wrote:



+= does *not* prevent re-evaluating the left side. It is internally
translated to x:=x+y and then evaluated like normal. So if x
contains a function call with side effects, these side effects are  
still

triggered twice.


Is evaluated as x := x + y or as x := x + (y)


FPC guarantees nothing about the order in which expressions are  
evaluated. FPC generally reorders expressions based on how many  
registers the compiler thinks it will need.



Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-03-28 Thread leledumbo
Hmm... Haskell? Or Nimrod? Or something else? What's the benefit? How will it
affect existing code? Last but not least, will you implement it?



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Feature-proposal-function-based-assignment-operators-tp5713868p5713870.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-03-28 Thread Benito van der Zander

What's the benefit?

Same benefit as += to := ... +

You do not need to rewrite/compute the left side

How will it affect existing code?

Not at all, since old code using this, would not compile

Last but not least, will you implement it?

I can try

On 03/28/2013 04:20 PM, leledumbo wrote:

Hmm... Haskell? Or Nimrod? Or something else? What's the benefit? How will it
affect existing code? Last but not least, will you implement it?



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Feature-proposal-function-based-assignment-operators-tp5713868p5713870.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-03-28 Thread Jonas Maebe

On 28 Mar 2013, at 17:50, Benito van der Zander wrote:

 What's the benefit?
 Same benefit as += to := ... +
 
 You do not need to rewrite/compute the left side

+= does *not* prevent re-evaluating the left side. It is internally translated 
to x:=x+y and then evaluated like normal. So if x contains a function call 
with side effects, these side effects are still triggered twice.


Jonas___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-03-28 Thread leledumbo
 Same benefit as += to := ... + 
 You do not need to rewrite/compute the left side

Save typing only then, the same mistake the C style operator support have
done.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Feature-proposal-function-based-assignment-operators-tp5713868p5713878.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Feature proposal: function-based assignment operators

2013-03-28 Thread leledumbo
 As to the C-style += operator, I have one question, will it makes code
slightly faster? because if you use Inc() or Dec() there will be a function
call?  or, the compiler will always try to inline Inc or Dec?

No, as been explained, it's internally translated to the equivalent non-C
style by the compiler. Inc/Dec is always processor's single inc/dec
instruction AFAIK (at least that's how it's implemented if you dig in to
their code).



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Feature-proposal-function-based-assignment-operators-tp5713868p5713893.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal