Open LonelyCat124 opened 3 years ago
Ok, so I randomly was looking for something else (using a terralib map
inside a generated task, which should be ok) and came across code just using a terralib struct as a field space - if that works I assume that is how creating metaprogrammed field spaces should be done?
Yes, Regent is compatible with Terra structs. The main limitation is you can't do things like parameterized fspaces this way (i.e. a field space that contains either regions or pointers into regions).
And yes, Terra structs currently have the best support if you need variable numbers of fields. If you just want to make the field names metaprogrammed, you can do that with fspaces and escapes.
At the moment the website suggests that
should be possible.
However, since
fspaces
are created in lua code (as opposed to terra or Regent code) I'm unclear how this is done, or if this can be done at all how I was expecting.From looking in the test suite, it is clear that this can be done for metaprogramming types pretty straightforwardly using:
and using
type
inside the field space to determine the types.What I'm trying to work out though is a little more complex. I have a "mapper" list, and an old field space, e.g.
What I'm trying to do is create a function that will create a field space from the mapper, such that each key of the mapper will be present in the new field space with the type of the corresponding field from the
part
field space, i.e. a field space:Pulling the required names and types is pretty straightforward, but I'm not sure how to then "insert" them into the generated field space. The best idea I have so far is to create an empty field space, and then modify the
fieldspace.fields
before returning the field space, but I'm not sure if that would work and it also feels likely to create bugs.Is this something thats intended to be doable? If so could an example be added into the documentation?