How to reference constant value from one in another?

15 views
Skip to first unread message

vlo...@gmail.com

unread,
Oct 4, 2019, 10:24:58 PM10/4/19
to Cap'n Proto
I was wondering if it's possible to derive one constant from another?

Something like:

struct Foo {
  a @0 :Float32;
  b @1 :Float32;
};

const oneWay :Foo = ( a = 1.0, b = 2.0 )
const orAnother :Foo = ( a = .oneWay.b, b = .oneWay.a )

And of course expanding this wondering if basic math operations like negation or even addition/subtraction are supported in these references?

Thanks,
Vitali

Kenton Varda

unread,
Oct 6, 2019, 3:30:35 PM10/6/19
to Vitali Lovich, Cap'n Proto
Hi Vitali,

At present the compiler does not support referencing a member of a constant, nor computing basic arithmetic, etc. I think it would be cool to add support for these things to the language, but personally I haven't yet had a need for it.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/31976e19-18e5-445c-914f-13d1be133f06%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages