[Oberon] INC(i) vs i := i + 1

Chris Burrows chris at cfbsoftware.com
Tue May 4 00:45:09 CEST 2021


> 
> From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Jeff
> Maggio
> Sent: Tuesday, 4 May 2021 1:50 AM
> To: oberon at lists.inf.ethz.ch
> Subject: [Oberon] INC(i) vs i := i + 1
> 
> Hi all,
> 
> In most Oberon source, people tend to increment i with INC(i). Is there an
> efficiency reason for this, or is i := i + 1 just as fast?
> 
> I'm trying to write code that would be very easy for someone coming from
> python/C++ to understand, so I'd prefer to use i := i + 1 because it's
> syntactically familiar
> 
> best,
> Jeff

My understanding is that if an experienced Python programmer just wanted to increment an integer variable they wouldn't write i = i + 1, instead they would write:

  i += 1

Similarly C++ programmers would write
  
  i++

INC(i) is the best match in Oberon for either of these statements.

I suspect they would be unhappy if you told them to rewrite this in Python / C++ as

  i = i + 1

so they would see this as a disadvantage if they were told that they had to write it this way in Oberon.

Regards,
Chris Burrows
CFB Software
https://www.astrobe.com






More information about the Oberon mailing list