<FromGitter>
<Blacksmoke16> this is also unfortunate
<FromGitter>
<Blacksmoke16> think the more specific overload is being added to the end, which never gets considered since the `_` overload matches everything
<FromGitter>
<Blacksmoke16> prob should just get rid of that
<FromGitter>
<Blacksmoke16> this would prob be handled via the orm component but 😬
<FromGitter>
<Blacksmoke16> if you're not using any serializer features could prob get away with just using json serializable, which would work in this case as there is an explicit method call, versus being based on overloads
<FromGitter>
<Blacksmoke16> or maybe a better solution would be some method that specific types could overload that by default returns self
aquijoule_ has joined #crystal-lang
richbridger has quit [Ping timeout: 256 seconds]
Xeago has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Ping timeout: 260 seconds]
deavmi_ has quit [Read error: Connection reset by peer]
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #crystal-lang
<FromGitter>
<HertzDevil> it happens because `SomeClass` is defined after an overload references it
<FromGitter>
<HertzDevil> some day i should translate restrictions.cr to plain english and put it on the repo's wiki or something
<FromGitter>
<mattrberry> Haha fair, don't even need the case statement :p Thanks!
daemonwrangler has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<asterite> I think it's a bug. I'll fix it. It probably also works if you use a newline instead of then
<FromGitter>
<Daniel-Worrall> I have a weird language feature I'd be interested to see. The ability to have the same method do different things based on whether what is calling it uses the value it returns. For example, recently we were talking about having an array method that mutates the array and returns the removed elements as an array. The user wanted to be able to use this without allocating that array that returns. If the
<FromGitter>
... compiler was aware of whether return values are desired, this array could go unallocated, and it'd be more performant at the cost of bin size/compile time/compiler complexity
<FromGitter>
<Daniel-Worrall> The way I imagine it in my head is either with a macro flag that is true whether or not the return value is used, or a way to define the same method (+sig) with a different return value (Maybe nil?) and the compiler be able to call the right one
<FromGitter>
<Daniel-Worrall> As I understand it the language only compiles/processes the methods that are called, so the compiler should be aware of where the call points are and be able to use that to determine which to call or not
<FromGitter>
<Daniel-Worrall> and I don't think I've ever seen this language feature elsewhere but please do tell me if you've seen this kind of thing before
<FromGitter>
<erdnaxeli:cervoi.se> that could be a nice feature
alexherbo2 has joined #crystal-lang
<FromGitter>
<naqvis> I would argue against such magical features as that makes things much hard to reason about. Its always good to be explicit then having things happening magically/silently. So far stdlib comes with bang(!) methods to tell that in-place mutation will happen (that's being explicit). ⏎ ⏎ There are languages which enforces the use of method return value (if explicitly stated in method signature) and ignoring
<FromGitter>
... that value is an error, but haven't seen any which changes the method behavior on using/ignoring its return value.
<FromGitter>
<Daniel-Worrall> Though it does seem like magic, I feel like it'd be the type of magic only the stdlib or very performant libs would be interested in. You get the optimisations without having to think about it. It could be introduced in the stdlib as a parameter instead of course. One thing that would concern me is ensuring that you get the same method behaviour for both cases
<FromGitter>
<HertzDevil> "very performant" code would simply not use the stdlib
<FromGitter>
<HertzDevil> 😂
<FromGitter>
<HertzDevil> happens to c++ all the time
<repo>
damn i love option parser <3 subcommands makes it really versatile
<repo>
also lazy block defaults for getters <3 very nice
<FromGitter>
<HertzDevil> til `T <= U` and `U <= T` do not imply `T == U` if they are types
hightower2 has joined #crystal-lang
<FromGitter>
<HertzDevil> and because of this, unions aren't even commutative
<FromGitter>
<HertzDevil> if we decide to remove `NamedTuple` what would double splats become?
<FromGitter>
<HertzDevil> keyword lists?
<FromGitter>
<HertzDevil> or `Tuple(Tuple(Symbol, T), ...)`?
tankf33der has joined #crystal-lang
<tankf33der>
o/
_ht has quit [*.net *.split]
fifr has quit [*.net *.split]
badeball has quit [*.net *.split]
holst has quit [*.net *.split]
jrayhawk has quit [*.net *.split]
jrayhawk has joined #crystal-lang
badeball has joined #crystal-lang
holst has joined #crystal-lang
_ht has joined #crystal-lang
fifr has joined #crystal-lang
postmodern has quit [Quit: Leaving]
<repo>
Blacksmoke16: sorry, I must be asking this for the fifth time, but how can i create a ParamConverter which takes a model class as a configuration argument and deserializes it from a json body?
<repo>
i tried setting configuration model : ASR::Serializable.class but it doesn't seem to recognize my model as such
<repo>
`Error: instance variable '@model' of Bucket::Converters::Record::Configuration must be Athena::Serializer::Serializable:Module, not Bucket::Models::Token.class`
<FromGitter>
<Blacksmoke16> `model : ASR::Serializable.class,` should be like the parent abstract class of whats possible for it to handle
<FromGitter>
<Blacksmoke16> like `Bucket::Models::Token.class`
<repo>
yeah i tried defining a base model abstract class, have that inherit Granite::Base and include ASR::Serializable but then i got some error about @validations already been set or something. lemme check
<FromGitter>
<Blacksmoke16> oh well if this is a db model you'd make it `Granite::Base.class`
<FromGitter>
<Blacksmoke16> ill see if i can reproduce with this paste
<FromGitter>
<asterite> HertzDevil: yes, the problems with T <= U and U <= T seem to always be related to the merge we do of tuples or named tuples. I'd like to remove that rule but I think by now it's too late
<FromGitter>
<HertzDevil> oh it's not a problem for tuples, only named tuples because the keys are ordered for `==` but unordered for `<=`
<FromGitter>
<asterite> HertzDevil: double splats would still be NamedTuple, but maybe you can't freely do `{a: 1, b: 2}`. That said, someone can do `def named_tuple(**args); args; end` so I guess there's no way to remove that. I just wish people would use more `record` and other types
<FromGitter>
<HertzDevil> key order also decides the named tuple's internal memory representation...?
<FromGitter>
<HertzDevil> imo named tuple keys should be unordered; if it's strictly for double splats i can't imagine a scenario where key order is important
<FromGitter>
<HertzDevil> either that, or always alphabetically ordered, as the compiler sometimes does that internally
<repo>
agreed
<FromGitter>
<HertzDevil> i mentioned keyword lists because that's what elixir uses and not only are named args ordered they can also have duplicate keys
<FromGitter>
<HertzDevil> maybe it's simply an erlang/beam limitation i don't know
<FromGitter>
<asterite> @HertzDevil yes, key order gives different named tuple types
<FromGitter>
<asterite> but when you do a union of two named tuples with the same keys, regardless of order, the compiler will not create a union but instead create a named tuple where each key is the union of the keys... I can't remember which order wins, but it's always the same
<FromGitter>
<asterite> I think in Elixir keyword lists are just lists of tuples, so duplicates are allowed
<FromGitter>
<HertzDevil> the first one
<FromGitter>
<HertzDevil> yeah
<FromGitter>
<HertzDevil> what's the reason for key order
<FromGitter>
<HertzDevil> to match `Hash`, or to use them in libs before lib structs were a thing?
<FromGitter>
<jrei:matrix.org> maybe to match Ruby
<FromGitter>
<Blacksmoke16> raz: i was able to reproduce
<repo>
yay!
<repo>
guessing you mean me
<FromGitter>
<asterite> You mean key order for named tuple?
<FromGitter>
<Blacksmoke16> oops, yea
<FromGitter>
<Blacksmoke16> i remember it started with an `r` and guessed wrong
<repo>
no harm done :D
<FromGitter>
<Blacksmoke16> but wasnt able to reproduce with example from the cookbook
<FromGitter>
<Blacksmoke16> > You shouldn't always use a struct, though. Structs are passed by value, so if you pass one to a method and the method makes changes to it, the caller won't see those changes, so they can be bug-prone. The best thing to do is to only use structs with immutable objects, especially if they are small.
<FromGitter>
<Blacksmoke16> second paragraph :P
<FromGitter>
<anapsix> yeah... who reads that far :P
<FromGitter>
<Blacksmoke16> didnt get to security related abstractions yet, so have to do some stuff on your own for now
<straight-shoota>
,
<repo>
this bothers me a bit: `if event.request.method == "POST" && {"/user", "/login"}.includes? event.request.path`
<FromGitter>
<Blacksmoke16> mhm
<repo>
i'd like to define this in the controller/action
<repo>
hm maybe i'll do it with a converter instead
<FromGitter>
<Blacksmoke16> i think we're talking about two diff things. that cook book example is for authentication. I.e. resolving a user from some form of token or something
<repo>
yeah, that's what i want
<FromGitter>
<Blacksmoke16> sounds like you want to add authorization logic to specific routes
<repo>
oh yeah
<FromGitter>
<Blacksmoke16> could probably do something like the pagination example. I.e. define some custom annotation that can be applied to specific routes that store data on the security "level", then would be able to check for that against the current user
<repo>
mhm
<FromGitter>
<Blacksmoke16> i really like the pagination example. Is one of the super cool things i like that im proud of 😆
<FromGitter>
<Blacksmoke16> not sure how you'd go about doing that in other frameworks 😉
<repo>
that's reeeeally cool *.*
<FromGitter>
<mattrberry> Ty Ary :)
xaxisx has joined #crystal-lang
<raz>
this m1 is a bit silly. "warning, your mac will sleep soon". 10% battery remaining. that's 2 hours lol
<FromGitter>
<Blacksmoke16> more like new battery
<raz>
yea the battery is nuts. 20h on full charge
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #crystal-lang
mertyildiran has joined #crystal-lang
<FromGitter>
<dansimpson> Hey folks, I am having some trouble with a multi-arch build. I am using docker to compile my program statically, and it works great for x64 using crystallang/crystal:0.35.1-alpine ... however, I can't find a matching aarch64 version of that image. When I use jhass/crystal:0.35.0-build-aarch64 which I found in the github workflows code, it doesn't seem to work. Is there an equivalent docker image to
<FromGitter>
... crystallang/crystal:0.35.1-alpine for arm architectures? I think part of this is my weak docker knowledge as well. Thanks.
<repo>
but it seems params not present in the json will be overwritten with nil
<FromGitter>
<Blacksmoke16> hmm
<FromGitter>
<Blacksmoke16> ill have to think about that one
<FromGitter>
<Blacksmoke16> from what i can tell they should be ignored
<repo>
hm
<repo>
nonetheless i get Save Exception: Bucket::Models::Token#user_id cannot be nil
<repo>
and i haven't sent user_id in the request. it's also not in the "update" group
<repo>
or is that the problem? everything not in the given groups will be set to nil?
<repo>
oh
<repo>
it's something else
<repo>
hm the object constructor isn't used at all
<repo>
maybe because i never required the file! time to go to bed... m(
<FromGitter>
<Blacksmoke16> :S sounds like it ha
<repo>
oh boy oh boy
<repo>
Blacksmoke16: damn, i'm so impressed by athena
<repo>
it's quite a steep learning curve but every time i need something done it kind of falls into place in a beatiful way in the end. I can really tell that a lot of thought has been put into it. Even more astonishing, as you've done it all by yourself.
<FromGitter>
<Blacksmoke16> ❤️ After a while i should hope everything clicks :) Benefit is you dont need learn it all at once, only when you need that feature
<FromGitter>
<Blacksmoke16> but i cant take all the credit...kinda just ported an existing framework into Crystal ha