google / wuffs

Wrangling Untrusted File Formats Safely
Other
4.16k stars 131 forks source link

Cannot declare constants using arithmetic expressions #6

Closed mvdan closed 6 years ago

mvdan commented 6 years ago

For example, this is very useful when declaring constant sizes in megabytes and kilobytes:

$ cat foo.wuffs
packageid "xxxx"

pri const maxSize u32 = 1 << 10 // 1KiB
$ wuffs-c gen -package_name xxxx foo.wuffs
invalid const value "1 << 10"

Would be neat if the compiler performed the calculation, similar to what the Go compiler does. For now, I'm just writing out the full numbers directly.

mvdan commented 6 years ago

Great - I was fearing this was left out on purpose :)