Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

JSON syntax #62

Closed
ntrel opened this issue Apr 4, 2019 · 4 comments
Closed

JSON syntax #62

ntrel opened this issue Apr 4, 2019 · 4 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@ntrel
Copy link
Contributor

ntrel commented Apr 4, 2019

I suggest the current syntax:
json.decode(User, data)
changes to:
json.decode<User>(data)

This is more consistent, as types cannot be values in V AFAIK. It also allows for the possibility that V will be able to implement json.decode as a generic function, with some future features.

@ntrel
Copy link
Contributor Author

ntrel commented Apr 4, 2019

As an example of decode<T> in V:
V already supports compile-time function execution. That could generate a string which could be turned into code (see D string mixins). The function would need a way of getting field names and types from a struct, and getting the element type of an array. This would all be slower to compile than implementing decode in the compiler, but these features are more flexible and powerful. It also means any other vendor implementing a V compiler doesn't need to implement decode if they include a library function instead (which might already exist by the V community).

@medvednikov
Copy link
Member

I'm not sure which syntax I prefer yet.

But I agree, that it should not be part of the compiler. Everyone will be able to write such code executed at compilation time.

@medvednikov
Copy link
Member

As of 0.0.5 json.decode<User>(data) syntax is used.

@ntrel
Copy link
Contributor Author

ntrel commented May 2, 2019

Great!

larpon pushed a commit to larpon/v that referenced this issue Feb 24, 2022
@medvednikov medvednikov added the Bug This tag is applied to issues which reports bugs. label Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

No branches or pull requests

2 participants