Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Native support for multi dimensional data types #215

Open
cmnrd opened this issue Sep 23, 2020 · 2 comments
Open

Native support for multi dimensional data types #215

cmnrd opened this issue Sep 23, 2020 · 2 comments
Labels
enhancement Enhancement of existing feature

Comments

@cmnrd
Copy link
Collaborator

cmnrd commented Sep 23, 2020

LF has a syntax for list types. For instance:

state foo:time[10]; // fixed size list of type time
state bar:int[]; // variable sized list of type int

List are treated differently in the targets. I believe C translates a list to an array. In C++, variable sized lists are translated to std::vector and fixed size lists to std::array. I am not sure what TS does, but I assume it also uses some kind of native list type.

Currently, LF only supports one dimension and it is not possible to define a matrix. Do you think we should also allow something like this?

state foo:time[10][3][8]; // fixed size matrix of type time
state bar:int[][]; // variable sized matrix of type int
state baz:time[][3][]; // mixed ??

I don't have a strong opinion about this. Extending the syntax seems simple, but it has the potential to cause some unforeseen problems down the road. Also note that the native target language types can always be used directly in (such as nested std::vector in C++). So we can write something like this:

state bar:{=std::vector<std::vector<int>>=};

But this does not work well for the time type.

@cmnrd cmnrd added the enhancement Enhancement of existing feature label Sep 23, 2020
@edwardalee
Copy link
Collaborator

In the C target, the time type is instant_t or interval_t. You can use these inside {= ... =}.

@lhstrh
Copy link
Member

lhstrh commented Sep 24, 2020

Yeah, if you use target types, you have to use the target type corresponding to time.

I believe the initial motivation for supporting lists came from the desire to be able to use clean list initializers for parameters, without having to surround them with {= =}. I guess using delimiters in type declarations of state variables is a little less bothersome. We could add support for higher dimensions, but I would consider this a low priority issue for now.

edwardalee added a commit that referenced this issue Dec 8, 2023
lhstrh pushed a commit that referenced this issue Jan 6, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

3 participants