Discussion:
[capnproto] Why is List(AnyPointer) not supported?
Ross Light
2017-08-27 03:31:11 UTC
Permalink
Hopefully a straightforward question: why does `capnp compile` have a
special case to error out
<https://github.com/capnproto/capnproto/blob/cc74158d90de65349b191dd93392003179823ae3/c%2B%2B/src/capnp/compiler/node-translator.c%2B%2B#L972>
on List(AnyPointer) and variants thereof? I don't have a burning need to
use it in a real schema — I came across this while I was trying to unit
test edge cases in some new go-capnproto2 code — but it surprised me. I
dug around in git history and it seems like it's been around since 2013
<https://github.com/capnproto/capnproto/commit/34e70d5acdceba9494025f9097feae599053b30a>,
and I don't see anything that helps me with rationale. I would expect it
to act as a non-composite pointer list.

Thanks for any pointers!
-Ross
--
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.
Visit this group at https://groups.google.com/group/capnproto.
Kenton Varda
2017-08-27 04:19:59 UTC
Permalink
IIRC it's because not all pointer types can legally exist as list elements,
since struct lists are supposed to be flattened. I was worried that someone
might assume that List(AnyPointer) (where each pointer is set to an
instance of MyStruct) would be compatible with List(MyStruct).

These days we also have AnyStruct, AnyList, and Capability. I think
List(AnyList) and List(Capability) ought to be made legal if they aren't
already (can't remember). Or in some use cases, it makes sense to replace
List(AnyPointer) with AnyList -- thus supporting lists of any type, as long
as all the elements are the same type.

-Kenton
Post by Ross Light
Hopefully a straightforward question: why does `capnp compile` have a
special case to error out
<https://github.com/capnproto/capnproto/blob/cc74158d90de65349b191dd93392003179823ae3/c%2B%2B/src/capnp/compiler/node-translator.c%2B%2B#L972>
on List(AnyPointer) and variants thereof? I don't have a burning need to
use it in a real schema — I came across this while I was trying to unit
test edge cases in some new go-capnproto2 code — but it surprised me. I
dug around in git history and it seems like it's been around since 2013
<https://github.com/capnproto/capnproto/commit/34e70d5acdceba9494025f9097feae599053b30a>,
and I don't see anything that helps me with rationale. I would expect it
to act as a non-composite pointer list.
Thanks for any pointers!
-Ross
--
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
Visit this group at https://groups.google.com/group/capnproto.
--
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.
Visit this group at https://groups.google.com/group/capnproto.
Ross Light
2017-08-27 04:58:46 UTC
Permalink
IIUC, the way the check is written it forbids any unbounded pointer,
including generic type parameters, AnyList, and Capability.

I don't care much either way. Makes it easier for me if the restriction
stays: less edge cases to test! :)

-Ross
Post by Kenton Varda
IIRC it's because not all pointer types can legally exist as list
elements, since struct lists are supposed to be flattened. I was worried
that someone might assume that List(AnyPointer) (where each pointer is set
to an instance of MyStruct) would be compatible with List(MyStruct).
These days we also have AnyStruct, AnyList, and Capability. I think
List(AnyList) and List(Capability) ought to be made legal if they aren't
already (can't remember). Or in some use cases, it makes sense to replace
List(AnyPointer) with AnyList -- thus supporting lists of any type, as long
as all the elements are the same type.
-Kenton
Post by Ross Light
Hopefully a straightforward question: why does `capnp compile` have a
special case to error out
<https://github.com/capnproto/capnproto/blob/cc74158d90de65349b191dd93392003179823ae3/c%2B%2B/src/capnp/compiler/node-translator.c%2B%2B#L972>
on List(AnyPointer) and variants thereof? I don't have a burning need to
use it in a real schema — I came across this while I was trying to unit
test edge cases in some new go-capnproto2 code — but it surprised me. I
dug around in git history and it seems like it's been around since 2013
<https://github.com/capnproto/capnproto/commit/34e70d5acdceba9494025f9097feae599053b30a>,
and I don't see anything that helps me with rationale. I would expect it
to act as a non-composite pointer list.
Thanks for any pointers!
-Ross
--
Post by Ross Light
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
Visit this group at https://groups.google.com/group/capnproto.
--
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.
Visit this group at https://groups.google.com/group/capnproto.
Loading...