eeprom record passed as a function parameter

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

Re: eeprom record passed as a function parameter

 · 
Posted: 29.05.2015 - 13:36  ·  #9
Hello Merlin,

This is perfectly valid for compiler:
Code
  if TEnum(One) > TEnum(Zero) then
    nop;
  endif;
and my code is no different, except that one var is in eeprom.

I respect your argument for disliking such enum comparison, but there is a reasonable case when such thing is needed and compiler should let me do it with eeprom vars when it lets me do it with ram vars. For example, I have an engine which triggers various TAlmLogLevel events of different importance like here (enums prefered over constants in this case):
Code
  TAlmLogLevel  = (evIrrelevant, evNormal, evImportant, evCritical);

Then I have a user setting stored in eeprom which filters what events shall be stored into flash memory. So, it is perfectly legit to compare event type with user defined filter (of the same type). Therefore I would still like it to be allowed without need for a workaround.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: eeprom record passed as a function parameter

 · 
Posted: 29.05.2015 - 14:15  ·  #10
As I say, Avra, more a comment than anything else. I think that

Code
if byte(One) > byte(Two) then


is perfectly OK. You are accepting that your set is ordered.

I don't like

Code
if One > Two then


I can see an argument for

Code
if TEnum(One) > TEnum(Two) then


because you then do not need to know the size of the underlying variable, so I am happy with that too. So I agree, your first work around should work, although I would still argue the original construct should not be valid.
  • 1
  • 2
  • Page 2 of 2
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   46   60 · Page-Gen-Time: 0.021001s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI