ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
lanodan has joined #crystal-lang
<FromGitter> <oliviahandoko> is there an equivalent of the def *init*(self, name): in Crystal? (name is an example
<FromGitter> <oliviahandoko> Python*
<FromGitter> <oliviahandoko> python to crystal equivalent*
<FromGitter> <Blacksmoke16> is that like a constructor?
<FromGitter> <oliviahandoko> yes
<FromGitter> <Blacksmoke16> ```class Person ⏎ def initialize(@name : String); end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ea62c5694ac2758e30db1dd]
<FromGitter> <Blacksmoke16> is the short form of
<FromGitter> <Blacksmoke16> ```class Person ⏎ def initialize(name : String) ⏎ @name = name ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ea62d6c501f8f72a507f449]
ur5us has quit [Ping timeout: 244 seconds]
ur5us has joined #crystal-lang
zorp has quit [Ping timeout: 260 seconds]
zorp has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8yni whats the reasoning the fiber object ID changes?
<FromGitter> <Blacksmoke16> i would have thought this would only instantiate the store once, and the object IDs of each `container` call be the same since the fiber is the same
<FromGitter> <Blacksmoke16> nvm, fiber ID is the same, but i still would have thought the others would be as well
zorp has quit [Ping timeout: 260 seconds]
<FromGitter> <Brodan> how do i assign something like `user.phone_number = phone if phone else ""`?
<FromGitter> <Blacksmoke16> `user.phone_number = phone`?
<FromGitter> <Brodan> if phone is empty will it set it to empty string by default or nil?
<FromGitter> <Blacksmoke16> would set it to whatever `phone` is
<FromGitter> <Blacksmoke16> do you not have validation to make sure its not nil or blank etc?
<FromGitter> <Brodan> its optional so it could be an empty field coming in from the view
<FromGitter> <Blacksmoke16> `user.phone_number = phone || ""`?
<FromGitter> <Blacksmoke16> or just keep it `nil` and use a default in the db?
<FromGitter> <Brodan> `phone || ""` seems to be what i was looking for. awesome thank you
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <kimvex> Hello a question, Crystal takes advantage of all the cores of a processor or was it only processed in a single core?
<FromGitter> <Blacksmoke16> when building something, or during runtime?
<FromGitter> <kimvex> during runtime
<FromGitter> <Blacksmoke16> atm crystal is only single threaded
<FromGitter> <Blacksmoke16> however, checkout https://crystal-lang.org/2019/09/06/parallelism-in-crystal.html for an intro to the experimental MT mode
<FromGitter> <kimvex> @Blacksmoke16 so imagine. I am developing an app and generating one thread per core, but that causes me problems with the mysql database connector. I didn't know why the problem was happening until I realized it could be because of the threads. So I wanted to know if with the last update of the language I automatically used the nuclei and no longer create the threads for me.
<FromGitter> <Blacksmoke16> its been an opt in feature for a while
<FromGitter> <kimvex> > however, checkout https://crystal-lang.org/2019/09/06/parallelism-in-crystal.html for an intro to the experimental MT mode ⏎ ⏎ thanks you
<FromGitter> <Blacksmoke16> so unless you been building with `-Dpreview_mt` then you have always been in single threaded mode
<FromGitter> <kimvex> > so unless you been building with `-Dpreview_mt` then you have always been in single threaded mode ⏎ ⏎ oh
<FromGitter> <codenoid> folks, stay home
Dreamer3 has quit [Quit: Leaving...]
<FromGitter> <watzon> No
dostoyevsky has quit [Ping timeout: 265 seconds]
dostoyevsky has joined #crystal-lang
ur5us has quit [Ping timeout: 244 seconds]
<FromGitter> <grkek> DENIED
<FromGitter> <neutrinog> how can I get the full namespace of a class? eg. `class.name` returns just the class name obviously. How can I also get `Name::Space::MyClass`?
<FromGitter> <galvertez> `{{@type}}` should work
<FromGitter> <neutrinog> oops. name does return all of that. Disregard. :P
alexherbo2 has joined #crystal-lang
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @lbarasti you are an elogant speaker, and good at explaining things. should do more vids!
Seich has quit [Quit: Gone fishing.]
<FromGitter> <lbarasti> @ImAHopelessDev_gitlab ❤️
<raz> +1 that video is awesome! (just had a peek and expected a quick rimer, but this is more like a full blown tutorial)
<raz> that could/should be added right to the crystal docs imho
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
alexherbo23 is now known as alexherbo2
<FromGitter> <3n-k1> is there a reason this code fails with `Error: expecting identifier 'class', not 'to_i64'`? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea6b27e3c03d320626e893a]
<jhass> have a look at the generated code https://carc.in/#/r/8yqk
<oprypin> foo : Int64?.to_i64
<oprypin> yay i guessed right
<FromGitter> <3n-k1> that tool will be so helpful, thank you very much!
<jhass> note the trick here is the call to debug()
<jhass> can do that locally too
<FromGitter> <3n-k1> oh nice, thanks for letting me know
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <fenicks> Hi everyone, ⏎ Do you know the right idiom in crystal to make a class not copyable? ⏎ I read about Reference Class and see a `dup` method but not the `clone` method, If I add a `raise` in an overriden `dup` method is it Ok? ⏎ ⏎ Thanks. [https://gitter.im/crystal-lang/crystal?at=5ea6c2d894ac2758e30f2d75]
<FromGitter> <straight-shoota> @fenicks What is your goal with this?
<FromGitter> <nodefourtytwo_gitlab> Hi, ⏎ ⏎ I'm trying to use UNIXSocket using the example in the doc: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5ea6c4c1f6a6e539797cceb1]
<FromGitter> <straight-shoota> @nodefourtytwo_gitlab `UNIXSocket` is the client socket. It doesn't create a new socket, it connects to an existing one. `UNIXServer` is the server socket.
<FromGitter> <fenicks> @straight-shoota I'm planning to implement something like Golang WaitGroup and learning the best way to do that in Crystal.
<FromGitter> <straight-shoota> But why do you want to forbid cloning an instance?
<FromGitter> <straight-shoota> btw. have you seen #6468?
<DeBot> https://github.com/crystal-lang/crystal/issues/6468 ([RFC] Structured Concurrency)
<yxhuvud> I suppose if you have a nursery with internal state you wouldn't want it dupped. Not certain how big of a problem it is in practice though.
<FromGitter> <fenicks> @straight-shoota To be sure that a WaitGroupe instance is uniq and protect some unsafe stuff. But to be honest I'm not sure if it's needed in Crystal.
<FromGitter> <fenicks> @straight-shoota I'll read it thanks.
<FromGitter> <nodefourtytwo_gitlab> @straight-shoota thanks! Though the example in the API Doc doesn't work either, when I checked the code https://github.com/crystal-lang/crystal/blob/master/src/socket/unix_server.cr there is a better example.
zorp has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <kingsleyh> afternoon - I have a thing which fires up many Fibers and they all go off and do their thing given some starting info - and they report back once their thing is done with the fruits of their labour. Sometimes while they are all off on their adventures the thing I asked them to do is no longer correct and now I need them to do almost the same thing but with a different bit of starting information. So I just
<FromGitter> ... fire up a bunch of new Fibers with the new tasks - however the previous guys are so excited by their research that they insist on wanting to tell me all about it which continues until they are all finished - I don't care about them anymore but i just don't know how to tell them. I want to let them down gently so my new guys ... [https://gitter.im/crystal-lang/crystal?at=5ea6f1a5568e5258e489c28c]
<FromGitter> <kingsleyh> I guess I could just try to ignore them?
<FromGitter> <Blacksmoke16> probably, afaik there isnt a way to "cancel" a queued/running fiber
<FromGitter> <kingsleyh> what would be the best way to ignore the ones that I don't care about? https://gist.github.com/kingsleyh/4f50ba826238c41519c9ff47374b9d64
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <kingsleyh> I could do something like `jobs.each{|job| job.ignore }` and then use that variable inside the job to stop it from reporting back it's info
<FromGitter> <kingsleyh> however I'm not sure the best way to do that
<FromGitter> <Blacksmoke16> have the channels return some struct with the data and context about that job, that you can then use when its received to determine what to do with it?
<FromGitter> <kingsleyh> is it bad to just close the channels for each job?
<FromGitter> <kingsleyh> the Fibers will still try to run I guess but they will find the channels are closed and so throw exceptions
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Channel.html#receive?-instance-method is an option
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 260 seconds]
<FromGitter> <oliviahandoko> is there an equivalent way of doing this from python to crystal?
<FromGitter> <oliviahandoko> this is all i have so far in crystal
<FromGitter> <Blacksmoke16> are those other ivars internal only?
<FromGitter> <Blacksmoke16> also whats with `name.attack_power` etc? isnt `name` a string?
<FromGitter> <Blacksmoke16> id consider using an enum for the type
<FromGitter> <Blacksmoke16> in regards to printing the stats, one option would be possibly override `.to_s(io : IO)`
<FromGitter> <Blacksmoke16> depends on how you want it to be used
<FromGitter> <oliviahandoko> inside the intialization is where I want all my pokemon characters to all have but current_hp and attack power is based on the specific pokemon I am using
<FromGitter> <Blacksmoke16> part of me thinks having a separate type for each pokemon would make sense, but that would be quite a lot of types...
<FromGitter> <Blacksmoke16> then you could have an abstract type to do common stuff and some protected methods to define stats of that particular one
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8yst this would be the equivalent for the constructor at least
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8ysu cleaned up a bit more
<FromGitter> <oliviahandoko> gotcha! Thank you so much. I will see what I can do from here
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> improvements/abstractions could deff be an option. however depends on the end goal of this if they would be worth it/which ones would make sense
<FromGitter> <oliviahandoko> hmmm.. if I create another class that inherits the Pokemon class, how do I call that class. Like if class PokemonOpponent < Pokemon
<FromGitter> <Blacksmoke16> call that class? meaning like within the constructor?
<FromGitter> <oliviahandoko> yes
return0e has joined #crystal-lang
alexherbo28 has joined #crystal-lang
Nekka has quit [Ping timeout: 260 seconds]
alexherbo2 has quit [*.net *.split]
return0e_ has quit [*.net *.split]
Vexatos has quit [*.net *.split]
Xeago has quit [*.net *.split]
alexherbo28 is now known as alexherbo2
Nekka has joined #crystal-lang
Xeago has joined #crystal-lang
Vexatos has joined #crystal-lang
hightower2 has joined #crystal-lang
<hightower2> Hey in regex, how would I specify both the atomic group and group name? I.e. I need to specify both (?> and (?<grpname>
Nekka has quit [Ping timeout: 240 seconds]
Vexatos has quit [*.net *.split]
Xeago has quit [*.net *.split]
Nekka has joined #crystal-lang
Vexatos has joined #crystal-lang
Xeago has joined #crystal-lang
<FromGitter> <Grabli66> Hi! I am trying to build static binary with docker crystal:0.34.0-alpine, but i am getting error undefined reference to `lzma_code'. What i am doing wrong?
<FromGitter> <j8r> Use rather `crystallang/crystal:0.34.0-alpine-build`
<FromGitter> <Blacksmoke16> shouldnt need that unless you're building the compiler
<FromGitter> <j8r> yeah, but it is convenient there are libraries
<FromGitter> <j8r> or add `apk add zlib-dev`
<FromGitter> <j8r> and `zlib-static`
<FromGitter> <Blacksmoke16> but it should already be there
<FromGitter> <Blacksmoke16> maybe just needs `zlib-dev`
<FromGitter> <Blacksmoke16> static is already there at least
<FromGitter> <j8r> that's strange to have only static
<FromGitter> <j8r> and not `-dev`
<FromGitter> <Blacksmoke16> ye, maybe make an issue/PR for it?
<FromGitter> <Grabli66> --link-flags "-lxml2 -llzma" fixes my problem :)
<FromGitter> <didactic-drunk> @kingsleyh Something like a waitgroup already exists CountDownLatch (https://didactic-drunk.github.io/concurrent.cr/Concurrent/CountDownLatch.html) thats designed for single producer wait until all tasks complete with error reporting.
Nekka has quit [Ping timeout: 260 seconds]
Nekka has joined #crystal-lang
<FromGitter> <kingsleyh> @didactic-drunk the problem is that after I spawned all the Fibers - I get an update - and I no longer care about those fibers - they are now in the way and I want to issue a new set
<FromGitter> <kingsleyh> but it's not possible to kill a Fiber - so they just continue on - which means they get in the way
Deuns has joined #crystal-lang
<Deuns> hello
<FromGitter> <Blacksmoke16> o/\
<FromGitter> <didactic-drunk> @kingsleyh Does each fiber have a possible break out point? Are they looping?
<FromGitter> <kingsleyh> this is a standalone version: https://gist.github.com/kingsleyh/4f50ba826238c41519c9ff47374b9d64
<FromGitter> <kingsleyh> then I have a loop higher up which keeps running the exec
<FromGitter> <kingsleyh> I've tried everything I can think of inside the Job class to stop the Fibers
<FromGitter> <kingsleyh> but they just keep running
<FromGitter> <kingsleyh> even if I close the channels - then they keep going but raise channel closed errors
<FromGitter> <kingsleyh> @didactic-drunk here is the bit that calls exec: https://gist.github.com/kingsleyh/5f7404de893d107fb175eef816a0c024
<FromGitter> <kingsleyh> I tried to set a variable when kill is called - @can_run - but it didn't help
<FromGitter> <didactic-drunk> Your loop rescue continues the loop. Is that intentional?
<FromGitter> <kingsleyh> @didactic-drunk here is the actual code in my branch: https://github.com/SushiChain/SushiChain/blob/no_tokoroten/src/core/miner/multi_process.cr
<FromGitter> <kingsleyh> @didactic-drunk well before I switched to trying to use multi-threading - I wanted to keep going on any errors
<FromGitter> <kingsleyh> but maybe that's not the right thing to do now
<FromGitter> <kingsleyh> the rescue only catches IO::EOFError though
<FromGitter> <didactic-drunk> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea728ad3c03d320627021be]
<FromGitter> <kingsleyh> hmmm
<FromGitter> <kingsleyh> the spawn and loop you are referring to is this one? https://github.com/SushiChain/SushiChain/blob/no_tokoroten/src/core/miner/miner.cr#L121
<FromGitter> <didactic-drunk> No, it was your original example. Am multitasking an losing track.
<FromGitter> <kingsleyh> the rescue was not rescuing much though - only EOFError
<FromGitter> <kingsleyh> if I close the channel then I get spammed with: Unhandled exception in spawn: Channel is closed (Channel::ClosedError)
<FromGitter> <kingsleyh> and the fibers continue going
<FromGitter> <kingsleyh> just getting spammed now
<FromGitter> <oliviahandoko> @Blacksmoke16 I am so confused. I created classes for individual pokemons but I am unsure how to make them "battle" eachother. In the python program, a friend and I made it looks like this
<FromGitter> <Blacksmoke16> @oliviahandoko figure it out? :p
<FromGitter> <oliviahandoko> @Blacksmoke16 sadly no
<FromGitter> <Blacksmoke16> got that example again?
<FromGitter> <Blacksmoke16> python is also pretty OO, so everything should be pretty much the same, just changes for syntax
<FromGitter> <Blacksmoke16> and have to be more explicit with types
<FromGitter> <oliviahandoko> yeah, I used sort of the same syntax but unsure what to do at the end? like how to call the classes?
<FromGitter> <oliviahandoko> this is what I added to the pokemon class?
<FromGitter> <oliviahandoko> in crystal
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea73561f6a6e539797e6c60]
<FromGitter> <Blacksmoke16> not sure i follow what the problem is/
<FromGitter> <Blacksmoke16> and you dont need `@name` to each method call
<FromGitter> <Blacksmoke16> like you would with `self` in python
<FromGitter> <kinxer> In fact, you *must* remove `@name` from your methods in order to call them in the way you want.
<FromGitter> <kinxer> Just to be clear.
<FromGitter> <kinxer> To be honest, I didn't expect the `@` syntax to work in "normal" methods: https://carc.in/#/r/8yua
<FromGitter> <kinxer> That is, in the method arguments.
<FromGitter> <Blacksmoke16> yea, is how setters work
<FromGitter> <Blacksmoke16> ```def something=(@name); end```
<FromGitter> <Blacksmoke16> you just dont have the `=` so yea
<FromGitter> <kinxer> But I guess `initialize` isn't really special from the point of view of the compiler.
<oprypin> kinxer, that's some choice words there
<FromGitter> <Blacksmoke16> in initialize its just sugar syntax for
<oprypin> oliviahandoko, are you the person who posted on reddit? good to see that you reached us here
<FromGitter> <Blacksmoke16> ```def initialize(name : String) ⏎ @name = name ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ea737511eb8bd3978fc3c42]
<FromGitter> <kinxer> Yeah... I realized immediately that it sounded like a dumb thing to say. :P
<oprypin> oliviahandoko, i like Python and Crystal and games. btw is this a game to be played only in a terminal (text)?
<FromGitter> <kinxer> Anyway, some part of me just took it as a given that the `def initialize(@something)` was *special*.
<FromGitter> <kinxer> 1) ~~*special*~~
<FromGitter> <kinxer> ... Not what I wanted.
<FromGitter> <kinxer> `~~*special*~~`
<oprypin> kinxer, no nothing dumb, i'm just talking about placeholder words in https://carc.in/#/r/8yua
<FromGitter> <kinxer> Oh, right. Yeah, I decided a few months ago that I'd rather just use words I enjoy typing and reading instead of always just doing `class A...`.
<FromGitter> <kinxer> I do tend to end up using words starting with A, though.
<oprypin> are there any nightly Crystal builds for mac?
<oprypin> i think there are; but where
<FromGitter> <Blacksmoke16> @oliviahandoko is there a specific error something you're running into?
<FromGitter> <kinxer> @oprypin Looking back at your message, I see that I misread "choice words" as "word choices"... Anyway, I appreciate your appreciation of the words I used.
<oprypin> :> sorry that it was unclear
<FromGitter> <kinxer> No worries. It was an error on the reading side, not the writing side. :P
<oprypin> and then this to install 'em https://gist.github.com/a2f4b29203936c04c578d6f6a1ad5f9b
<FromGitter> <straight-shoota> oprypin, do you have some feedback on my response in #9169 ?
<oprypin> straight-shoota, ech i started to write something semi-angry, as i know for sure that i've had that use case so many times before and i'm passionate about it, but in the end maybe it isnt essential and maybe you're right
<oprypin> still disagree with the auto-fallback method though. so what if you happened to run into many cases where they want the fallback. still write it out explicitly, it's better to see that, otherwise the reader has to look that up
Nekka has quit [Ping timeout: 264 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
Nekka has joined #crystal-lang
straight-shoota has joined #crystal-lang
<straight-shoota> Yeah, I can relate to both your points
<straight-shoota> I understand the use cases for `is_path_under_base` an I'm pretty sure we should have that as a feature. But it requires different considerations than `relative_to`, so it probably needs a custom implementation.
<straight-shoota> So far I haven't run into a single case that didn't want to fall back to the non-relativized path. And that makes sense considering that this feature is to be meant to shorten paths to make them nice for display.
<straight-shoota> It's just a convenience feature. If the path can't be made shorter, you use the explicit one.
<FromGitter> <didactic-drunk> How do I disable exhaustive case?
<FromGitter> <watzon> I don't believe you can, but you can just throw an `else` in there
_ht has quit [Quit: _ht]
<FromGitter> <Blacksmoke16> im just going to ignore him now
<FromGitter> <Blacksmoke16> is like girng but less friendly :P
<jhass> hehe, I decided to start hiding their posts or isolating them into new topics you can just ignore ;)
<FromGitter> <watzon> What'd I miss? Lol
<FromGitter> <Blacksmoke16> guy on the forums whos mad because overflows raise an exception versus just defaulting the the type's max value
<FromGitter> <Blacksmoke16> to the*
<jhass> their just generally mad to be honest :P
<FromGitter> <watzon> Lmao, time to go check the forum I guess
<straight-shoota> I understand the general attitude is not welcoming.
<FromGitter> <didactic-drunk> @watzon Exhaustive case fails with many shards. It's too much work for me to fix every one.
<straight-shoota> jhass, I'm not sure the comment on CEF should be hidden. https://forum.crystal-lang.org/t/cef-chromium-embedded-framework-with-crystal/2010/2
<FromGitter> <watzon> Ahh, yeah afaik there's no way to turn it off
Seich has joined #crystal-lang
<jhass> straight-shoota: tone is clearly off and nothing productive added
<jhass> I mean just look at the further responses in the thread now....
<straight-shoota> Yeah, the general conduct is not acceptable
<straight-shoota> But the individual comment just states the rightful opinion on the topic
<oprypin> wait is that IRC i see
<straight-shoota> It's certainly not ideal at this point. But if the comment was from someone else, would you have flagged it?
<jhass> straight-shoota: I disagree. That opinion is completely irrelevant to the discussion.
<jhass> in that tone? yes
<jhass> in a more civil tone I would be more undecided
<straight-shoota> I don't think the opinion is generally irrelevant. If someone asks how to shoot themselves in the foot and I'm convinced that's not a good idea I'd definitely point that out.
<FromGitter> <j8r> jhass @Blacksmoke16 he has an emotional overflow 😂
<straight-shoota> But I agree that the way it's presented doesn't help
<FromGitter> <j8r> first time I see straight-shoota on IRC
<jhass> straight-shoota: what's the benefit? There's zero content in there. There's no "why" this is a bad idea. There's no alternative/easier solution hinted at. There's zero value.
<straight-shoota> It could spark a deeper discussion ¯\_(**)_/¯
<FromGitter> <watzon> Seems like his main concern is that you can't do what he wants as a one liner
<straight-shoota> @j8r I've been on IRC before occassionally
<FromGitter> <watzon> Which is idiotic. It's pretty easy to catch the overflow exception and set the value to the max manually.
<straight-shoota> Now it's because my ISP is having connectivity issues since a few hours and at some point Gitter stopped working ^^
<straight-shoota> Maybe their interchange is infected with covid-19 :D
<FromGitter> <j8r> possible :)
<FromGitter> <j8r> talking about overflow
<raz> what software is the forum running on btw?
<FromGitter> <j8r> not really sure how to fix
<raz> it's pretty nice
<FromGitter> <watzon> 😂
<straight-shoota> Haha, it turns more and more into comedic entertainment
<straight-shoota> "Also, your post makes no sense. You can’t overflow something if it defaults to the max value." LMAO
<FromGitter> <watzon> raz it's Discourse
<raz> ah nice
<oprypin> 😂
<oprypin> thanks @jhass
<FromGitter> <j8r> Let's default to MIN in overflow and MAX in underflow, so it makes a loop
<FromGitter> <watzon> Oof ok, IEatReturnValues just isn't gonna learn
<FromGitter> <watzon> I don't get people like that
<FromGitter> <j8r> His name makes no sense also
<FromGitter> <watzon> Seems like the typical uneducated noob I see in Telegram groups every day
<FromGitter> <watzon> Thinks his way is the best, no matter how many times you explain why it's not
<FromGitter> <didactic-drunk> I'm still leaning towards troll. Or half troll/slime.
<jhass> slime is new to me
<jhass> what's a slime?
<FromGitter> <Blacksmoke16> in other news, i finished the rewrite of my DI shard. https://github.com/athena-framework/dependency-injection/blob/di-refactor-v2/spec/service_mocks.cr are examples of the syntax/usages if anyone has feedback 😄
<FromGitter> <watzon> I've seen so many complete morons on Telegram that actually think this way, I have a hard time seeing someone like that as anything but the same
<FromGitter> <didactic-drunk> https://www.dandwiki.com/wiki/Slime
<straight-shoota> great to see the reactions from the community, though. Everyone's being nice about it
<FromGitter> <watzon> Hahaha DnD reference. I like.
<FromGitter> <didactic-drunk> Often considered brainless.
<FromGitter> <watzon> Brainless and toxic
<FromGitter> <watzon> follows
<FromGitter> <didactic-drunk> Wait, can I be mean? Shit. I missed an opportunity for free therapy.
<FromGitter> <watzon> I want to know who pissed in their corn flakes
<FromGitter> <watzon> Every thing you say, doesn't matter what it is, they just pick out something to be mad about rather than listening
<FromGitter> <watzon> It's like talking to a toddler
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> made it so you dont have to include a module anymore, and also auto resolves dependencies
<jhass> okay guys, please remember this is a public and logged space. please move any discussion persons to DMs, thanks :)
<FromGitter> <Blacksmoke16> tried to*
<FromGitter> <watzon> Very cool @Blacksmoke16 😄
<FromGitter> <Blacksmoke16> *magic*
<FromGitter> <watzon> I'm going back to working on an ORM I had started on months ago
<FromGitter> <kinxer> I just read through that overflow thread... Oof. On a side note, I wish I'd read through bdcardiff's solution before posting myself; an LLVM builtin solution is almost certainly going to work better than a pure Crystal implementation.
<FromGitter> <watzon> With module based models rather than abstract classes
<FromGitter> <Blacksmoke16> a repo approach to decouple the model and the logic to query/save would be nice
<FromGitter> <watzon> @kinxer at the very least it will likely be faster, but they don't seem happy with any of the answers
<FromGitter> <Blacksmoke16> but gets tricky w/o reflection as wouldnt have a way to set the auto `id`
<straight-shoota> watzon, Hmm there are already so many ORMs that it's hard to choose. Please make sure yours stands out =)
<FromGitter> <kinxer> Yeah... I think the way I'd want to handle it from a ui standpoint is with generics, which I think would satisfy his (?) desire to use `+` with impunity.
<FromGitter> <Blacksmoke16> make it work with annotations
<FromGitter> <watzon> I'm working on it haha. Unfortunately none of the current ones fit my use case. I just want creating models to be as easy as `JSON::Serializable` is.
<FromGitter> <watzon> @Blacksmoke16 that's the idea
<FromGitter> <Blacksmoke16> granite works like that fwiw
<FromGitter> <Blacksmoke16> `column` macro just defines an ivar with an annotation
<FromGitter> <Blacksmoke16> are some open issues/PRs that would allow for a bit more but :shrug:
<FromGitter> <watzon> Still working on the API I want, but this is basically what I have right now https://github.com/watzon/gravity#usage
<FromGitter> <Blacksmoke16> yea similar to granite
<FromGitter> <Blacksmoke16> you have that working, or what you want the end result to be?
<FromGitter> <watzon> That's what I want the end result to be. It is very similar to granite, but for the module based approach. Tbh if granite just used modules I could probably make it work for my use case.
<FromGitter> <watzon> I tried implementing the change myself, but there's a lot to work around
<straight-shoota> watzon, I suppose the difficult part is keeping track of changes to the properties
<FromGitter> <Blacksmoke16> `@[Gravity::HasMany(Chat, lazy: true)]` ill be curious if you get it to work
<FromGitter> <Blacksmoke16> `user = User.new(id: 1234, first_name: "John", last_name: "Doe")` also may i suggest *not* supporting magic initializers behind the scenes
<FromGitter> <watzon> Yeah that's gonna be one of the hard parts
<FromGitter> <watzon> Why no magic initializers?
<FromGitter> <Blacksmoke16> its hard to get right
<FromGitter> <Blacksmoke16> might give some insight
<FromGitter> <Blacksmoke16> having it work well with serialization is also tricky
<FromGitter> <Blacksmoke16> like supporting (de)serializing the models directly
<FromGitter> <watzon> Hmm yeah I'll have to think about that. I like having `.new` and `.create` methods built in that automatically take the expected values.
<FromGitter> <Blacksmoke16> `User.new(id: 10).save`?
<FromGitter> <Blacksmoke16> just gets tricky on how to handle edge cases like preventing people from manually setting auto int PKs
<FromGitter> <Blacksmoke16> but yea, keep me posted. last i remember some of it wont be easy w/o nilable properties
<FromGitter> <Blacksmoke16> `{{ table ? table[:name] : @type.name.underscore }}` would use the full namespace of the type, prob with the `::` as a heads up
<FromGitter> <watzon> Didn't think about that
gangstacat has quit [Quit: Ĝis!]
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> @straight-shoota any word on the bdwgc release?
<straight-shoota> I have no idea. Don't even recall where it was semi-officially mentioned
<straight-shoota> But I know I came across it again since I told you about it, so I didn't make it up.
<straight-shoota> At least it's proven to me =)
<FromGitter> <Blacksmoke16> :sad: okay
Nekka has quit [Ping timeout: 240 seconds]
straight-shoota has quit [Ping timeout: 240 seconds]
straight-shoota has joined #crystal-lang
<straight-shoota> Maybe it's better to build our own then...
<straight-shoota> Feel free to post a PR^^
Nekka has joined #crystal-lang
<straight-shoota> watzon, don't feed... =)
<FromGitter> <watzon> I'm done lol
<FromGitter> <Blacksmoke16> i might give it a try, imagine just need to copy whats in the linux/Dockerfile?
<FromGitter> <Blacksmoke16> be nice to be able to use MT in that image
<FromGitter> <didactic-drunk> How do I control the number of threads? Is there an environment variable?
<FromGitter> <Blacksmoke16> `CRYSTAL_WORKERS`
<FromGitter> <kinxer> You can't overload the assignment operator, right?
<jhass> not for locals
<jhass> or any kind of variables. for properties on objects yes
<jhass> that's how setter/property works. Just defining def foo=(value) style methods which can be called like ob.foo = value. So technically there's no assignment operator in there, it's just parsed as a call. But it sure looks like one
Nekka has quit [Ping timeout: 264 seconds]
<FromGitter> <watzon> @Blacksmoke16 any idea how I'd get the generic for of `@type`? So the value of `T` in `struct Foo(T)`
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#7210610 (master - Add .each and .each_with_index to various macro types (#9120)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/680325413
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9120 (Add .each and .each_with_index to various macro types)
<FromGitter> <Blacksmoke16> cant just use `T`?
<FromGitter> <Blacksmoke16> or `@type.type_vars` or something like that
<FromGitter> <watzon> I remember T not working in macros, but I could try again
<FromGitter> <Blacksmoke16> has to be within a method iirc
Nekka has joined #crystal-lang
straight-shoota has quit [Ping timeout: 264 seconds]
straight-shoota has joined #crystal-lang
<FromGitter> <kinxer> Another question: is there any way to test compile-time behavior? In particular, I'd love to specify that trying a certain thing raises a compile-time error.
<FromGitter> <Blacksmoke16> is how i been doing it
<FromGitter> <Blacksmoke16> is kinda slow but :shrug:
<FromGitter> <Blacksmoke16> https://github.com/athena-framework/dependency-injection/blob/di-refactor-v2/spec/compiler_spec.cr started doing it this way, a bit cleaner
<FromGitter> <watzon> @Blacksmoke16 In keeping track of changes to a record, I'm going to set a `modified` flag on a field when its value gets set. Do you think I should still set the flag if the value was set, but not actually changed? (Meaning they set it to the same thing it already was)
<FromGitter> <watzon> My thought it yes, just in case the value was modified outside the scope of the ORM
<straight-shoota> Blacksmoke16, yeah it's basically already in the Dockerfile for the linux build
<straight-shoota> the port definition seems pretty straightforward too: https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/gc/APKBUILD
<FromGitter> <Blacksmoke16> now i just need to up my Make game
<FromGitter> <Blacksmoke16> i imagine we want to grab the patch from the linux dir? or just duplicate it within the docker dir?
<straight-shoota> The patch shouldn't be necessary anymore
<FromGitter> <Blacksmoke16> oo right
<straight-shoota> I don't think it is actually used in the current process
<FromGitter> <Blacksmoke16> it is
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea76dc5fa8ed04cb2c90166]
<FromGitter> <Blacksmoke16> within `linux/Dockerfile`
<FromGitter> <Blacksmoke16> prob since we're pinned to latest release which doesnt have the patch
<straight-shoota> right
<FromGitter> <Blacksmoke16> so we would still need it
<straight-shoota> Or just pull a pinned commit from master
<FromGitter> <Blacksmoke16> that could work
<FromGitter> <Blacksmoke16> also where does `/usr/share/crystal` come into play, build is failing because it doesnt exist
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea76e861b61f5706fab157e]
<straight-shoota> that should've been in the targz
<straight-shoota> it's extracted at /usr
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> naw, even master atm fails for me
<FromGitter> <Blacksmoke16> `make alpine DOCKER_REPOSITORY=crystal-lang/crystal DOCKER_TAG=nightly CRYSTAL_VERSION=0.34.0 CRYSTAL_TARGZ=0.34.0.tar.gz`
<FromGitter> <Blacksmoke16> unless i need to have the targz at some specific location?
<FromGitter> <Blacksmoke16> hold on, i might have the wrong targz