zorp has quit [Read error: Connection reset by peer]
ur5us has joined #crystal-lang
<repo>
Depends on the country :)
<repo>
if there’s anything like social structures in place you end up earning less. (Unlike in the US where each individual has to pay for everything)
<FromGitter>
<3n-k1> does crystal have anything like C#'s `base()`? essentially, reusing an already existing constructor from a super class while still adding functionality to it?
<FromGitter>
<stronny> `super` ?
<FromGitter>
<3n-k1> i must've been using that wrong, i could never get that to work
<FromGitter>
<3n-k1> that makes sense now that i think about it
<FromGitter>
<stronny> `super` without args calls parent's new with your args
<FromGitter>
<stronny> `super` with args calls parent's new with what you've passed it
<FromGitter>
<stronny> this problems seems to be related to instance vars, not really calling parent's contrunctor per se
<FromGitter>
<3n-k1> is there anything similar to this that works for methods other than constructors? for instance, if i just want to slightly wrap a super classes method?
<FromGitter>
<stronny> maybe I'm wrong about constructors now that I think about it
<FromGitter>
<Blacksmoke16> actual `Without arguments or parentheses, previous_def receives the same arguments as the method's arguments. Otherwise, it receives the arguments you pass to it.`
<FromGitter>
<Blacksmoke16> i didnt test it but it seems it does
<FromGitter>
<stronny> interesting
chachasmooth has quit [Ping timeout: 256 seconds]
chachasmooth has joined #crystal-lang
snosk8r has quit [Read error: Connection reset by peer]
<FromGitter>
<paulcsmith> Hello! I’m planning to upgrade https://github.com/luckyframework/dexter to the new Log in 0.34. I’m having trouble finding the formatted option though? Does the new Log not allow setting for ⏎ matters? Or maybe it just isn’t documented?
<FromGitter>
<paulcsmith> Of course right after I post I find it ;)
<FromGitter>
<stronny> so I have a question about GC. When I do `a = slice.new(10)` the allocated buffer lives in `a` and a has a pointer to its first byte and its size, no problem. If later I do `b = a + 5`, now `b` has a pointer to some random byte, so how does GC manage these cases?
<FromGitter>
<stronny> I mean when does it free `a` and/or `b`?
yxhuvud has quit [Remote host closed the connection]
<FromGitter>
<ImAHopelessDev_gitlab> hi
<jhass>
> Pointers from the stack or registers may point to anywhere inside an object.
<raz>
hrmpf. these golang PR-reviews are getting on my nerves. 300 lines of boilerplate for what would amount to 10 lines in a proper language. and then another 50 of tests.
<raz>
github really needs a 'convert to crystal' button
<FromGitter>
<asterite> raz what's an example golang PR you were looking at? (just out of curiosity)
<raz>
asterite: company code so can't share. but am tempted to say... pick any golang PR ever ;)
<raz>
the verbosity is just absurd. and the awful syntactic mix between JavaStyleVeryLongIdentifiers and perl'esque line noise *->:= doesn't help my migraine either.
<raz>
if err != nil { fmt.Println("exceptions are too complicated for you. let's code like in the 1960s, much safer!") }
DTZUZU2 has joined #crystal-lang
DTZUZU has quit [Ping timeout: 256 seconds]
sorcus has quit [Ping timeout: 252 seconds]
sorcus has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
DTZUZU2 has quit [Ping timeout: 258 seconds]
DTZUZU2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter>
<alehander92> i still think errors maybe ok
<FromGitter>
<alehander92> you can see that many languages like rust, haskell and much more
<FromGitter>
<alehander92> dont really use a lot of exceptions, but they offer nice abstractions/syntax sugar for their results
<FromGitter>
<alehander92> exceptions are not really complicated, but type safety with them is
postmodern has joined #crystal-lang
<FromGitter>
<ImAHopelessDev_gitlab> golang helped me tremendously to want to use crystal
<FromGitter>
<ImAHopelessDev_gitlab> same for rust's syntax
lvmbdv has quit [Quit: bye]
lvmbdv has joined #crystal-lang
early` has quit [Quit: Leaving]
rohitpaulk has joined #crystal-lang
early has joined #crystal-lang
<FromGitter>
<kinxer> I haven't used Go, but Rust does have some cool features that would be nice in Crystal, like defining methods on a generic type only when it has a particular type variable and, of course, exhaustive case statements (which it seems like Crystal will get!).
<FromGitter>
<tenebrousedge> yes, exhaustive case has been merged
<FromGitter>
<kinxer> Excellent. Is it likely to make it into the next release, then?
<FromGitter>
<tenebrousedge> I didn't look but I would assume so
<FromGitter>
<tenebrousedge> conditional method definition like that doesn't seem like it would be possible
<FromGitter>
<tenebrousedge> although I'm not quite sure what you're talking about
<FromGitter>
<asterite> yes, exhaustive case will be in the next release as a warning. Later on it will be an error
<FromGitter>
<asterite> @kinxer "like defining methods on a generic type only when it has a particular type variable" -> can you show an example of that? (a link)
<FromGitter>
<kinxer> I'm a novice at Rust (not a lot of opportunity to use it so far...), but I understood trait implementations like in that link as filling a similar role to generic types.
<FromGitter>
<kinxer> Though I guess Traits are more like generic *modules*.
<FromGitter>
<stronny> so what is it that can you do in rust with traits that you can't do in Crystal?
<FromGitter>
<asterite> I guess in Rust you can define methods only on Array(Int64) but not on other types
<FromGitter>
<asterite> How does that show up in docs?
<FromGitter>
<kinxer> It does make the docs somewhat messy (to a newcomer, at least).
<FromGitter>
<asterite> Also, in Crystal we might not need that. `Enumerable` defines `sum` and that only works if methods have a `+` method, but that is implicit... the method "exists" for all types but only compiles for certain types
<FromGitter>
<asterite> Also, you can always do `{% if T ... %}` inside the method and raise at compile time if T isn't what you expected. Then the method will appear in docs but you can say "But this only works if..."
<FromGitter>
<kinxer> Yeah, the implicit requirements like that do exist, and they make the language more flexible, but they aren't particularly self-documenting.
<FromGitter>
<asterite> It's true
<FromGitter>
<kinxer> Yeah. I think I've done that at some point with something...
<FromGitter>
<kinxer> Anyway, this isn't really an actual feature request. I don't feel strongly that the Rust-like generic-implementation stuff actually belongs in Crystal.
<FromGitter>
<stronny> I guess sometimes I wish I could say `class Tree(T : Int)`
<FromGitter>
<stronny> but that's not a huge deal breaker for me
<FromGitter>
<kinxer> I just know that I've run into cases in the past in which I thought that it would be nice to have (though I can't remember off-handedly what I was trying to do when I thought that).
<FromGitter>
<asterite> I think adding methods to specific generic instances is possible (from the perspective of how the compiler is implemented), but we'll need to see how to document those. Also it comes together with how to constraint types. Maybe you want to apply a method to `Array(Int)` where `Int` can be `Int32`, `Int64`, etc., so that's like `Array(T) where T < Int` but there's no such thing in the language... so it's a huge
<FromGitter>
... change... for maybe not a common use case
<FromGitter>
<stronny> `Array(T : Int)`
<FromGitter>
<stronny> even backwards compatible
<FromGitter>
<stronny> or Int.class if you insist
<FromGitter>
<kinxer> Yeah... I do think the generic type constraints would be useful, though, from the point of view of easily giving more useful compile-time errors (e.g. `generic type of X must be a Y` instead of a message about missing some method).
<FromGitter>
<kinxer> That syntax is also semantically consistent with the rest of the language.
<FromGitter>
<stronny> that should support modules too
<FromGitter>
<stronny> T : Enumerable
ur5us has joined #crystal-lang
<FromGitter>
<stronny> and then we'll get the generics overloads like `Array(T : Enumerable), Array(T : Bool?), Array(T, N)` lol
<FromGitter>
<stronny> Crystal++
<FromGitter>
<kinxer> What's that last one you have? `Array(T, N)`?
<FromGitter>
<stronny> I guess in ++ you could also overload on the value of N even
<FromGitter>
<stronny> `Array(Int, 3) or whatever`
<FromGitter>
<stronny> I didn't think that one through, but I could imagine something
<FromGitter>
<kinxer> Isn't that how `StaticArray` already works?
<FromGitter>
<stronny> yeah
<FromGitter>
<stronny> so you could drop it in favour of a single template!
<FromGitter>
<stronny> (I'm mostly joking here)
<FromGitter>
<kinxer> Yeah, I was slow on the uptake but realized that.
<FromGitter>
<asterite> The problem is, what happens if you add a method to `Array(T : Foo)` and then to `Array(T : Bar)`, both modules, and a type includes both? It becomes a bit confusing. The current way is simple: there's only one definition for all types
<FromGitter>
<kinxer> I use C++ a lot for my job, but we don't really use any templating (or really any new language features from the last two decades except STL containers and looping over them), so some of my coworkers joke that we just use C+.
<FromGitter>
<asterite> :-D
<FromGitter>
<kinxer> Yeah, in that example with two modules, I guess it would either depend on ordering of something somewhere (my vote would be the order of the `include`s) or give an error about conflicting definitions.
<FromGitter>
<stronny> what's the rule with overloading now?
<FromGitter>
<stronny> what if I have `method(x : Enumberable)` and `method(x : Indexable)` and call `method([1,2,3])`?
<FromGitter>
<kinxer> Also, what happens right now when you include two modules with the same method in a single class?
<FromGitter>
<stronny> the second one will shadow the first one I imagine
<FromGitter>
<Blacksmoke16> @kinxer figured out why the validator is not compile time safe
<FromGitter>
<Blacksmoke16> i have a type that returns the validator to use given a context, `@constraint_validator_factory.validator constraint`. however since the return type is the interface, which would essentially be a union of all validators, it doesnt know which specific validator it will be
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter>
<bcardiff> In a couple of hours nightlies should be published again 🎉
<FromGitter>
<Blacksmoke16> \o/
<FromGitter>
<bcardiff> This is not an april fools update