mudasobwa
Pyc → Structs on Steroids
Blog post, announcing Pyc package. It allows transparent validation across inserted data with Exvalibur, chaining functions in a monadic-like way, and exposes all the keys as local variables inside methods declared with defmethod (without compilation warnings.)
It also reasonably implements Access behaviour for wrapped structs and Collectable protocol with validation.
Most Liked
benwilson512
Hey @mudasobwa. It’s always great to see people take on problems.
There’s a few thing about these libraries that would make them more likely to be used by others. The first big one for Exvalibur is making the source code more readily available. The hexdocs don’t link to any source code, and I couldn’t find it with some cursory googling either. I had to create a project, add it as a dep, and then open the deps directory to get a look at it.
The code contains a LOT of Code. function calls. This is almost always a sign that things aren’t quite right. A lot of it is to support the strings which, as @OvermindDL1 notes, is completely unnecessary because of Elixir’s built in macro support.
benwilson512
Ah, that’s my mistake, the https://hexdocs.pm/exvalibur/exvalibur.html page looked like the top module doc and I looked for </> and didn’t see it. I see the code now, I wonder why it wasn’t higher on google.
As far as the macros go, it’s a pretty large topic. I’d consider the guides, and the Metaprogramming Elixir book. I’m a little short on time at the moment but I may be able to comment later with more details. The short version is that your Code.string_to_quoted is what the compiler already does. Try using just is_map(val) and see what the input to your function is.
The functions inside Code should basically never be called at runtime. They’re not optimized for it and can lead to a variety of issues.







