eeprom record passed as a function parameter

  • 1
  • 2
  • Seite 2 von 2
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: eeprom record passed as a function parameter

 · 
Gepostet: 29.05.2015 - 13:36 Uhr  ·  #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
Geschlecht:
Alter: 25
Beiträge: 1474
Dabei seit: 03 / 2005
Betreff:

Re: eeprom record passed as a function parameter

 · 
Gepostet: 29.05.2015 - 14:15 Uhr  ·  #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
  • Seite 2 von 2
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 15 · Cache Hits: 14   46   60 · Page-Gen-Time: 0.026059s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI