Replies: 2 comments
-
Hmm one problem: providing an inline bsn list is now ambiguous with providing a single BSN: // before
bsn! {
Node [
{children}
]
}
// after
bsn! {
Node
// this expects an `impl Scene` not an `impl SceneList`
{children}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's a random shower thought: define the entire hierarchy upfront, and then create the specific entities directly at their correct level. Just spitballing here! bsn! {
{
bg
bg_top
bg_top_label
bg_checkbox
bg_bottom
},
bg{
Node { width: px(100) }
BackgroundColor(GREEN)
}
bg_top{
Node { width: px(10) }
BackgroundColor(RED)
}
bg_checkbox{
: checkbox
InteractionDisabled
Children[
Text("Hello there")
]
}
bg_bottom{
Node { width: px(10) }
}
}
bsn! {
{
*bg
**top
***top_label
**checkbox
**bottom
},
bg{
Node { width: px(100) }
BackgroundColor(GREEN)
}
top{
Node { width: px(10) }
BackgroundColor(RED)
}
checkbox{
: checkbox
InteractionDisabled
Children[
Text("Hello there")
]
}
bottom{
Node { width: px(10) }
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a potential alternative BSN syntax that attempts to resolve some issues with the current BSN syntax. It comes down to introducing new
<>
syntax to indicate the bounds of an Entity.First, here is an example with the current
bsn!
syntax:And here is the
<>
syntax:Resolved Issue: Over-indentation / newlines
In the current syntax, children with more than one component use
()
for clarity. This sadly results in both over-indentation and unnecessary newlines:The proposed
<>
syntax resolves these problems:Resolved Issue: Eliminates the
RelationshipTarget []
vsComponent []
ambiguityThe current
[]
shorthand forChildren []
creates ambiguities withSomeParentComponent []
andRelationshipTarget []
. This new syntax removes the[]
shorthand, freeing upRelationshipTarget []
(if we still want it in this new world ... coming up a with a new syntax might be better).Resolved Issue: Syntax Noise
Currently defining children involves a mix of
[]
,()
, and,
:<>
syntax cuts this down substantially:Resolved Issue: Child misalignment
Currently for terseness, children don't require
()
wrappers for small numbers of components:This makes it visually challenging to pair
#Child1
and#Child2
together.<>
syntax would be required, which forces a "pairing" between them:Resolved Issue: Where to put commas
The current BSN syntax has rules that feel a bit "arbitrary". Components within a single entity do not use comma separators, lists of entities do:
Some people find this confusing / arbitrary.
<>
removes the comma case from the "structural BSN syntax", reserving it only for initializing rust types:BSN currenty exists in a middle ground where it largely feels like Rust, but it makes targeted departures from Rust syntax in the interest of ergonomics or clarity. This creates a kind of "wait why aren't there commas here" discomfort in some people, as it feels like a violation of Rust-like expectations (ex:
(Node Marker)
when defining a child entity instead of(Node, Marker)
). Adding commas to that case feels ergonomically non-viable to me in the context of BSN.The proposed
<>
helps resolve that discomfort by more fully decoupling ourselves from the Rust context.<>
feels less "Rust-ey" and more "user-interface-ey". When defining hierachies in<>
elsewhere (ex: the web), people expect no commas:We're just replacing these attributes with components (and abandoning the "closing" aspect of XML):
Resolved Issue: Removes an annoying "syntax refactor" case
Currently, adding a component can force a move from the "shorthand" approach to the
()
wrapper approach:With
<>
syntax, this is not necessary:New Issue: What do we do for custom relationships?
Previously, all "hierarchical relationships" felt the same:
We will almost certainly lose that pairing in the new world, and are likely to lose the "shared levels of indentation".
New Issue: XML / HTML similarity
<>
introduces a similarity to XML / HTML that may cause some developers to wrongly assume they are compatible. I personally think this is worth it.Note that I think embracing more XML syntax would make things worse (ex: "closing syntax like
</div>
" or<button />
syntax would degrade our ergonmics)Alternative: Use
()
instead of<>
Pros:
Cons:
Losing special "entity syntax" means it is harder to pick out entities / children from other rust code. Everything starts to blur together. Consider this:
Perhaps too Rusty ... people expect to use commas inside
()
I'm personally still biased toward
<>
.Beta Was this translation helpful? Give feedback.
All reactions