Macros currently can't be used to express nodes of any type, with properties (that aren't "fields", but rather set_
prefixed methods) in arbitrary order and possibly omited. Example:
- Note: general node methods are chainable. For instance,
node.set_skin(skin)
returnsNode
,node.append_children(iterable)
returnsNode
andbutton.set_warning(is_warning)
returnsArc<Button>
.- Note: Here,
Node
holds an internalArc<NonRefNode>
.
- I wish
markup! { <Button warning={true}/> }
to expand to:
Button::new(|btn| btn.set_warning(true))
- I wish
markup! { <Row></Row> }
to expand to:
Row::new(|row| row).append_children([])
- I wish
markup! { <Button skin={specific_skin}/> }
to expand to:
Button::new(|btn| btn).set_skin(Some(specific_skin))
// ... where `set_skin` comes from my base `Node` type, not `Button`
I think this macro would have to be designed at the language-level, requiring some constraints and some orientations given at the node itself, so that Rust knows what markup!
has to do with the types.
I'd use that markup specifically NOT for writting websites, but rather generic applications, such as these developed with Unreal Engine, Adobe AIR, Flutter and Microsoft Silverlight.
Post from the other community: