"with" does not work as expected

Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

"with" does not work as expected

 · 
Posted: 09.09.2014 - 14:46  ·  #1
Code
  // this compiles:
  with Runtime do
    General.Powerup.Moment.Year := RTCgetYear;
  endwith;

  // this does not compile "Error: var or symbol expected":
  with Runtime.General.Powerup.Moment do
    Year := RTCgetYear;
  endwith;

with is of not much use if 2nd example can not compile. Can this be fixed?
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: "with" does not work as expected

 · 
Posted: 09.09.2014 - 20:17  ·  #2
Hello Avra,
delphi doesn't anymore recommend "with" in their latest compilers.
Our AVRco only supports "with" within simple records because it
doesn't work in a nested/recursive manner.

Furthermore contrary to big machines (386 etc) "with" doesn't show
any effort with AVRs and similar in most cases. Take a look onto the
ASM output of AVRco.

I for myself doesn't use any withs in AVR since a long time because
of this reasons/limitations.

Your problem with the Runtime error will be investigated.

rolf
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: "with" does not work as expected

 · 
Posted: 10.09.2014 - 09:29  ·  #3
Thanks Rolf,

I rarely use "with", but for assignments to deeply nested record members it is very helpful. I don't need it for anything else. Benefit is not typing savings, because copy/paste solves that. Benefit is the readability. My longest record member in current project has full name length twice as "Runtime.General.Powerup.Moment" from the example, and it is also an array, so when I use assignments to copy from one record member to the other visible editor line is not enough to show full assignment. With 24 assignments one bellow the other readability is completely lost and I have to put much effort when looking at the code, since while I come to the end of the line I almost forget what was at line start.

Avra
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   58   72 · Page-Gen-Time: 0.020857s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI