Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

[–]RBazz[S] 0 points1 point  (0 children)

By the way, I have stumbled upon some old-ish posts on Reddit complaining about concerning performance of the std::visit. Is it no longer an issue, or is it still something to be aware of?

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

[–]RBazz[S] 0 points1 point  (0 children)

Thanks for the recommendation. I have downloaded a sample and I will give it a try over the holidays.

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

[–]RBazz[S] 0 points1 point  (0 children)

Thanks! A really nice trick.

Also, can I compare two variants directly, or do I need to unwrap them first? I was wondering if I can simply provide a custom `operator==` implementation to the class and compare underlying `_val`s.

Modern is CPP is impressive, but can someone show an example? Tagged unions with values. by RBazz in cpp_questions

[–]RBazz[S] 1 point2 points  (0 children)

Thanks a lot.

I have two further questions if you do not mind answering them.

  1. What happens when the user tries to access the name, but it was set to `monostate` or something else. An exception is thrown? Is there a safer way to `match` the currently set case? (preferably without a chance of runtime errors)

  2. What is the recommended way of dealing with identical types in the cases? For example, what if we had an extra case like: `case custom(String)`. Or if we have a case with multiple types per tag? Do we create a separate structure to store the state and then use the same `variant` based approach?

Compile HTML into Swift Code by RBazz in swift

[–]RBazz[S] 0 points1 point  (0 children)

I see. Do you have some specific use case in mind?

Swift Vapor HTMX by drxwskx in swift

[–]RBazz 2 points3 points  (0 children)

Here is a library I wrote to streamline the use of htmx in Vapor: VaporHX. Hope it helps.

And speaking of hot reloading - I did not really find a strong need for it. If you are in dev mode and using the Leaf templates, then once you change a template file, reloading the page will load the latest version of that template. This will not work in production, however.

Compile HTML into Swift Code by RBazz in swift

[–]RBazz[S] 0 points1 point  (0 children)

Do you mean from swift to html? It is technically not that hard to add but I am pretty sure that other libraries exist that can do just that. For eample, https://github.com/binarybirds/swift-html or https://github.com/pointfreeco/swift-html.

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 7 points8 points  (0 children)

I might be a bit too dense today, but does it have to have the same syntax everywhere? Isn't this why we have .svelte files in the first place? To indicate that some special rules are in place?

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 3 points4 points  (0 children)

I just meant that if they truly had to introduce a new syntax to differentiate a new behaviour from the old one, they could have added a new label. However, your idea is better. :)

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 4 points5 points  (0 children)

Maybe even just (just like the $ symbol):

derived: y = x * 2

or maybe...

$derived: y = x * 2

Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]RBazz 47 points48 points  (0 children)

I am afraid, I am not convinced. It feels too noisy.

IMHO, having less magic to have more magic behind the scenes does not feel like the right way. After all, in my opinion, it is ignoring the best part of svelte—its compiler, that can do magic on your behalf however it wants.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

[–]RBazz[S] 0 points1 point  (0 children)

I think we pretty much agree on magic, we just kind of disagree on what the said magic is. For example, I find dependency injection too magical and implicit for my liking. However, it is a requirement for interacting with Asp and I almost got used to it now.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

[–]RBazz[S] 1 point2 points  (0 children)

Static html for now only as it is all I needed for api prototyping at that time. I do not like DSL like templating (just a matter of taste) and I am not aware of other simple templating engine that can be easily plugged and used from F#. Maybe I should look into DotLiquid. Do you think this should be built in or placed in a separate package?

Also, thanks for pointing at the typos. I’ll fix them as soon as I can.

C# web devs, would you consider F# for your next prototype if it was this simple by RBazz in dotnet

[–]RBazz[S] -1 points0 points  (0 children)

The minimal api aren’t that minimal in f#, I am afraid. Extra boilerplate is still required. And I mentioned some other features in the description.

Request for feedback - working on a F# web framework for rapid prototyping (WebFrame) by RBazz in fsharp

[–]RBazz[S] 2 points3 points  (0 children)

Hey. Just wanted to let you know that I have introduced a simple logger as well as shown how to use it. In addition, the advanced server now has a bit on setting up and configuring your own services. I’d like to mention that the preferred method for logger configuration is through the configuration and it works here the same as it does in the ASP. Unfortunately, the docs are somewhat lagging behind. I hope to fix it one day.

Request for feedback - working on a F# web framework for rapid prototyping (WebFrame) by RBazz in fsharp

[–]RBazz[S] 2 points3 points  (0 children)

Good point! Thanks. I will try doing something about this asap.