Replies: 5 comments 4 replies
-
@philpax Hm so the schema might be part of the problem, but there's more that's missing that I think makes it harder:
Moving to a custom syntax wouldn't (at least immediately) help with any of those. Other paths we could explore:
|
Beta Was this translation helpful? Give feedback.
-
kdl is a super cool language kthxbai |
Beta Was this translation helpful? Give feedback.
-
Another potential alternative: StrictYAML. There's a Rust crate from last year that we could potentially resurrect. This could benefit from all of the existing tooling around YAML validation. |
Beta Was this translation helpful? Give feedback.
-
A more experimental idea: we have a proc macro inside Rust that updates the ambient_api::schema! {
#[description("The player's body's entity ID")]
#[attributes(Debuggable, Networked)]
component player_model_ref: EntityId;
#[name("FPS Player")]
#[description("A player in a FPS gamemode.")]
concept FpsPlayer {
is_fps_player = (),
// can leave out default values if there's no meaningful default, which can't be done with TOML at present
player_model_ref,
}
#[description("Handles input")]
message Input {
shoot: Bool,
direction: Vec2,
}
#[description("Describes the state of a player")]
enum PlayerState {
/// Waiting to spawn
WaitingForSpawn,
/// Alive
Alive,
}
} automatically edits the [component.player_model_ref]
type = "EntityId"
description = "The player's body's entity ID"
attributes = ["Debuggable", "Networked"]
[concept.FpsPlayer]
name = "FPS Player"
description = "A player in a FPS gamemode."
[concept.FpsPlayer.components]
is_fps_player = {}
player_model_ref = {}
[message.Input]
description = "Handles input"
[message.Input.fields]
shoot = { type = "Bool" }
direction = { type = "Vec2" }
[enum.PlayerState]
description = "Describes the state of a player"
[enum.PlayerState.members]
WaitingForSpawn = "Waiting to spawn"
Alive = "Alive" Advantages:
Disadvantages:
|
Beta Was this translation helpful? Give feedback.
-
The more time passes, the more I'm thinking that we should build a custom IDL with all the usual accoutrements (syntax highlighting, LSP). TOML will get better (the new version enables multiline inline tables! yay!) but there's still an obvious friction from trying to specify data and hierarchies in a format that's clearly not meant for it. I think this would look a lot like WIT, as it's a very similar problem. |
Beta Was this translation helpful? Give feedback.
-
Opening this up for discussion, but this will probably not happen for a while.
A common complaint I've seen amongst package users is that the TOML syntax for specifying package items (components, concepts, etc) can be confusing/counterintuitive, especially with error handling, and it's not always the most obvious how to naturally extend something. This is one of the bigger issues mentioned in #693.
The largest issue people have is TOML's poor support for nested tables - if they have something like
you cannot actually break the table onto multiple lines:
You must either use an inline single-line table (which grows unwieldy with more fields)
or use a separate table (which requires restructuring your TOML / looks ugly):
To fix this, we can either find a more relaxed format for the manifest (I'm partial to KDL), or we can break the schema out of the manifest and implement our own grammar for it. The latter would enable us to be much more lenient with parsing and to improve error handling.
This might also be necessary if we start supporting defining more complex types in our schema, like custom structs and such.
The syntax bikeshed is not open - especially as we don't know if we're going to do this - but a reasonable first pass would be something like
or a more attribute-based approach:
(but please don't read too much into the details of these, these are just examples of what's possible!)
Beta Was this translation helpful? Give feedback.
All reactions