If I were to write a non-zero value into bar, emboss_prelude.h:185 EMBOSS_CHECK(result); wouldn't execute and the write would succeed. It wouldn't be until I called bool Ok() that I would find out that something was written incorrectly. At that point, I just get a boolean true or false and not a directed, clear result of what went wrong.
This isn't the case if I place the [requires] block on the field itself:
struct Foo:
0 [+1] UInt bar
[requires: this == 0]
This second Emboss definition would catch the non-zero write via emboss_prelude.h:185 EMBOSS_CHECK(result);. Regardless of where the [requires] block is placed, we should catch incorrect writes when they happen.
Suppose I have the following Emboss definition:
If I were to write a non-zero value into
bar
,emboss_prelude.h:185 EMBOSS_CHECK(result);
wouldn't execute and the write would succeed. It wouldn't be until I calledbool Ok()
that I would find out that something was written incorrectly. At that point, I just get a booleantrue
orfalse
and not a directed, clear result of what went wrong.This isn't the case if I place the
[requires]
block on the field itself:This second Emboss definition would catch the non-zero write via
emboss_prelude.h:185 EMBOSS_CHECK(result);
. Regardless of where the[requires]
block is placed, we should catch incorrect writes when they happen.