As a Frontend developer, I'm used to composing multiple function together to create inherently a tree structure of dom nodes, as this is most of the code i produce it should be as syntax less as possible and specialities should stand out as i care more about these.
fn HomePage() {
var currentUser = await query.getActiveUser()
val blogs = await query.getCurrentBlogs()
LimitedContentWidth {
NavigationBar {
Logo
Label("My Personal Blog 🤩")
Spacer
Link("GitHub", "https://github.com/")
Link("Discord", "https://discord.gg/")
if currentUser {
ProfilePicture(currentUser)
} else {
LoginButton
}
}
Section {
Label("Latest News")
List(blogs) { blog ->
Card {
Label(blog.title)
Flex {
Spacer
Label(blog.blogUrl)
}
}
.backgroundImage(blog.backgroundImage)
}
}
}
}
Milestone: 0.3.0.
I'm still of the idea that this should be done with macros instead of like the way swift does it (which is what I assume your syntax is inspired by). Interesting proposal though, we'll see what @paperdave thinks.
i have no idea what i am looking at or what this proposal is.
LimitedContentWidth { what is this syntax structure? a struct literal has fields.
List(blogs) { blog -> what is this?
can you give a full example of what you want to specifically change in the language, otherwise i will close this.
Imagine a function definition of
fn LimitedContentWidth(block: () -> void) { [...] }
Now you could write it as
LimitedContentWidth(() -> {
})
But my proposal states that it should be possible to simplify these callbacks to
LimitedContentWidth {
}
Still exactly the same code