RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
Renich has quit [Ping timeout: 250 seconds]
jemc has quit [Ping timeout: 244 seconds]
tilpner_ has joined #crystal-lang
RX14- has joined #crystal-lang
tilpner has quit [Disconnected by services]
tilpner_ is now known as tilpner
blassin has quit [Ping timeout: 240 seconds]
RX14 has quit [Remote host closed the connection]
thews has quit [Ping timeout: 240 seconds]
Renich has joined #crystal-lang
blassin has joined #crystal-lang
jemc has joined #crystal-lang
jemc has quit [Client Quit]
jemc has joined #crystal-lang
<FromGitter> <anamba> did anyone else chime in yesterday on an easy way to work on shards locally? if not, here is an improved version of the script i posted yesterday to replace `lib/myshard` with a symlink. obviously you could do this by hand, but doing it several times a day becomes tedious very quickly. https://gist.github.com/anamba/4b30076c6f9869b041d592c4347d8e11
<FromGitter> <Blacksmoke16> you know you can give your shards a reference to a directory
non-aristotelian has quit [Quit: non-aristotelian]
<FromGitter> <anamba> @Blacksmoke16 yes, but then i have to remember not to commit that :)
<FromGitter> <anamba> some days that's easier said than done
<FromGitter> <Blacksmoke16> :p fair enough
<FromGitter> <anamba> i suppose with my way, i do sometimes forget to update shard.lock, which is not quite as bad, but still not good
<FromGitter> <girng> https://play.crystal-lang.org/#/r/5pyq i'm using a signed 16bit integer
<FromGitter> <girng> but it lets me set it past the value of `65,535`
<FromGitter> <girng> what am i doing wrong
<FromGitter> <girng> ohhh https://play.crystal-lang.org/#/r/5pyw/edit works here though
<FromGitter> <girng> wtf hahaha
<FromGitter> <girng> so if it's a property it assigns the 16 bits to it. and that's the max. but if it's just a local variable/variable or whatever, it change dynamically dependent on what value you give it? can fluxuate between 16bits, 32bits, etc, etc?
<FromGitter> <Timbus> youre reassigning the variable.. you could do `a = 10; a = "string";` too..
<FromGitter> <girng> but i initially set the variable to use 16 bits only, just like how i would in a class
<FromGitter> <Timbus> you didn't. you just assigned a variable to an int that was 16 bits. this doesn't limit future assignments
<FromGitter> <Timbus> you want `number : Int16 = 0`
<FromGitter> <girng> i see, so the "limit future assignments" only happen if it's assigned a type in a Class property?
<FromGitter> <Timbus> it just needs to have a type constraint at some point
<FromGitter> <girng> yeah i just figured i didn't need to do the `: Int16` part, because i don't do that for my class properties and it restricts the type. but i guess if i don't use property macro, i need to restrict it. thanks!
<FromGitter> <anamba> still working with the phusion passenger team to figure out why passenger and `HTTP::Server` don't seem to get along. anyone have any idea what 3rd thing HTTP::Server might be doing, other than either accepting the connection or returning a ECONNREFUSED? https://github.com/phusion/passenger/issues/2144#issuecomment-445394338
<FromGitter> <proyb6> ```Array(myStruct).new``` took 120+ns to create new array, can it gets faster?
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #crystal-lang
jemc has quit [Client Quit]
<FromGitter> <girng> this a good way to check if an array has valid indexes that are in a hash?
<FromGitter> <girng> it's working 100%, and i like it but just curious if i'm doing it the right way lol
<FromGitter> <anamba> @DanilaFe you are pretty quick! i haven't had to do this kind of stuff since maybe soph year of college time. which for me, was like 18 years ago.
<FromGitter> <DanilaFe> Fortunately for me, this *is* my first sophomore year of college :)
<FromGitter> <anamba> getting a good brain workout from aoc.
<FromGitter> <DanilaFe> I managed to scored in the top 100 a couple of days in 2017, so I'm trying to recapture that. Closest I've gotten was 200 though :(
<FromGitter> <anamba> wow nice. wait, i got 187 yesterday
<FromGitter> <anamba> maybe you finished right between when i submitted and when i checked the leaderboard :)
<FromGitter> <anamba> i thought you beat me yesterday
<FromGitter> <DanilaFe> Yesterday wasn't a good day for me, actually
<FromGitter> <DanilaFe> I did pretty well on part 1 but took a solid hour on part 2
<FromGitter> <anamba> ok, i must have been thinking of another day, heh. yesterday's was extremely straightforward for me. (also i wanted to finish quick to try smash bros)
<FromGitter> <DanilaFe> The first part was straightforward, but I still can't come up with a good solution for part 2. I had to study for an exam, but abandoning the problem was not an option
<FromGitter> <anamba> i actually could have finished yesterday's part 2 a lot quicker except that i misread, and used a <= instead of < 😒
<FromGitter> <anamba> my one chance at a top 100 finish...
<FromGitter> <DanilaFe> I was actually having a similar issue. Kind of unfortunate
<FromGitter> <DanilaFe> There's still, what, 18 days left?
<Yxhuvud> yawn.
<FromGitter> <DanilaFe> oh hey, @Yxhuvud, aren't you the #2 from the leaderboard?
<Yxhuvud> yes
<FromGitter> <DanilaFe> how's this advent of code going for you?
<Yxhuvud> so-so
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <anamba> looking for a shard that makes use of the mozilla public suffix list to figure out the "base" domain name, given a string. like this: https://github.com/weppos/publicsuffix-ruby i haven't found one yet... i will probably have to make it. but if anyone knows of something similar, please let me know!
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <girng> that gonna be a lot of ifs πŸ˜†
<FromGitter> <proyb6> I wonder if converting someone's Day 8 ruby code to crystal got an error, does it work on Crystal with ```times.map```? ⏎ Spoiler: ⏎ https://gist.github.com/proyb6/95fa3e6bb6e6de9feabcfde75bfa0bd4
<FromGitter> <DanilaFe> The error is: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c0b6e2de4787d16e362c364]
<FromGitter> <DanilaFe> according to carc.in
<FromGitter> <DanilaFe> this is because of type inference
<FromGitter> <DanilaFe> Basically, the type of parse_node depends on the type of the map call, which depends on parse_node
<FromGitter> <DanilaFe> try parse_node(data).as Node
<FromGitter> <DanilaFe> this makes the type of map known, which then makes the type of parse_node known
<FromGitter> <proyb6> I see, I read Yxhuvud's code now as well
<FromGitter> <DanilaFe> I also got this error today
<FromGitter> <proyb6> That's magical to me in this puzzle
<FromGitter> <r00ster91> I don't quite understand why I'm getting this error: https://carc.in/#/r/5q12 ⏎ It only happens with the `spawn do`, this works: https://carc.in/#/r/5q13
<FromGitter> <r00ster91> And when I change the first 4 lines to something simpler then it works as well: https://carc.in/#/r/5q14
<FromGitter> <r00ster91> Why is `time` having the type `(Int32 | Nil)` in the first example?
<FromGitter> <proyb6> It mean if it's not an int, it's a nil
<FromGitter> <r00ster91> Well but it is an Int32 which you can see if you comment out the `sleep`: https://carc.in/#/r/5q19
<FromGitter> <girng> πŸ€·β€β™‚οΈπŸ˜’
ashirase has quit [Ping timeout: 246 seconds]
<jokke> eheheh don't try this at home: https://p.jokke.space/BQo3q/cr (AoC related)
ashirase has joined #crystal-lang
<FromGitter> <asterite> compiler bug, but it's because time is closured
<FromGitter> <r00ster91> alright I will open up an issue
<FromGitter> <asterite> it already exists
<FromGitter> <asterite> search immutable vars
<FromGitter> <asterite> it's similar
<FromGitter> <r00ster91> ah ok
<FromGitter> <girng> im trying to change a property of a class by a string https://play.crystal-lang.org/#/r/5q31/edit ⏎ use case: i have skill tree data, and each node modifies the player's stats. want to do it all in one loop instead of a bunch of if statements using .notation
<FromGitter> <girng> IF It can only be done with a macro, please don't show me how just give me a starting point where to look. because i can learn if i do it with a macro by myself
<FromGitter> <r00ster91> I'd do it with a Hash: https://play.crystal-lang.org/#/r/5q3s
<FromGitter> <girng> yah was thinking about that
<FromGitter> <r00ster91> but you can try doing it with a macro as well. Hint: you have to pass a Player object to the macro and you need to define the macro with `macro`
<FromGitter> <girng> ok
<FromGitter> <girng> @r00ster91 so i can't actually put any macro code inside the []=(name, value) part?
<FromGitter> <girng> instance_vars
<jokke> asterite: would there have been any way to make the code i pasted above work? i tried casting the result of chain to Iterator(Node) but that just triggered an infinite loop while compiling until i was out of ram
<FromGitter> <r00ster91> you need to put your macro stuff inside a `macro`, not a `def`
<FromGitter> <r00ster91> you can put macros everywhere
<FromGitter> <proyb6> I'm thinking how would you rename ```Node``` to ```Tree``` instead because it's easier to read and it's 🌲
<FromGitter> <r00ster91> you can solve the problem by having only one macro in your class and the properties @girng ⏎ you dont need a def and a macro
<FromGitter> <asterite> jokke: what code?
sagax has quit [Read error: No route to host]
<foxxx0> when I'm defining a custom class with some properties, how do I need to write the #initialize() so that some properties are optional and they are properly initalizes with e.g. an empty array
<foxxx0> ah, just specify default values for the arguments in the #initialize()...
<RX14-> good news: you'll get to play with your favourite spinny logo on the new crystal forums :) http://owo.sh/3b9f9b.png
RX14- is now known as RX14
<FromGitter> <vladfaust> Nice!
<FromGitter> <proyb6> Cool! But spinny logo can be non-animated?
<FromGitter> <proyb6> I want a dark mode forum :)
literal has joined #crystal-lang
<FromGitter> <drum445> Anyone want to test my match 3 game ;) ⏎ https://zaybul.com/game/
<FromGitter> <j8r> πŸ‘for dark mode
bmcginty has quit [Ping timeout: 252 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <j8r> @drum445 tried. Good job!
<FromGitter> <drum445> Thanks man. Trying to clean up the animation a bit but I think the core engine is in place
<jokke> asterite: this one https://p.jokke.space/BQo3q/cr
<jokke> it'd be so awesome if that just worked
<FromGitter> <proyb6> Thought I got this out of bound error? Spoiler Day 8 code ⏎ Unsure if it's correct code or a bug may be related https://github.com/crystal-lang/crystal/issues/7160? ⏎ https://carc.in/#/r/5q6o
<FromGitter> <proyb6> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c0bc256f992693c7a401437]
<jokke> asterite: i get an generic type too nested error if i try that
<FromGitter> <asterite> then i guess there's no way to do it
<jokke> mmh
<FromGitter> <asterite> the iterator results in an infinite recursive type
<FromGitter> <asterite> and because crystal doesn't have interfaces nor virtual dispatch there's no way to represent that
S0bait has joined #crystal-lang
<S0bait> Afternoon
<S0bait> When Crystal creates an app via `crystal init app <app_name>`, how do run the build command? From the way the command seems to be laid out, it seems we need to have a "root module" in src?
<FromGitter> <drum445> if your app_name is project
<FromGitter> <proyb6> ```crystal build --release --no-debug``````
<FromGitter> <drum445> you can run ⏎ crystal src/project.cr
<FromGitter> <drum445> or to build ⏎ crystal build src/project.cr --release
<S0bait> The default gitignore blacklists `/bin`
<S0bait> the generated binary from above command is in the root of the project.
<S0bait> Should that be changed? Additionally, is it never possible for a crystal project to currently build multiple binaries?
<Yxhuvud> You can add compile targets to your shard file.
<Yxhuvud> There is also nothing that stops you from putting things in a makefile and orchestrate from that
<FromGitter> <asterite> You can also run shards build
<FromGitter> <asterite> that will put the binary in `/bin`
<FromGitter> <asterite> S0bait: for multiple targets use `shards`, check this: https://github.com/crystal-lang/shards/blob/master/SPEC.md#targets
<FromGitter> <asterite> `crystal` is the "dummy" compiler: takes a file (and dependencies from it), compiles it to an executable. `shards` is higher level in that it will put it in `bin`, allow to compile multiple targets, etc.
jemc has joined #crystal-lang
jemc has quit [Ping timeout: 244 seconds]
jemc has joined #crystal-lang
jemc has quit [Ping timeout: 246 seconds]
sagax has joined #crystal-lang
_whitelogger has joined #crystal-lang
S0bait has quit [Quit: Connection closed for inactivity]
<FromGitter> <bhargavrpatel> How do i change the time that appears on gitter
rohitpaulk has joined #crystal-lang
<FromGitter> <delef> https://play.crystal-lang.org/#/r/5q85 ⏎ why?
jemc has joined #crystal-lang
<FromGitter> <r00ster91> You need to tell Crystal the type: https://play.crystal-lang.org/#/r/5q8f
<FromGitter> <delef> Why does autodetection type not work in this case?
<FromGitter> <r00ster91> It would probably be possible to type infernce this as well. But I think it would probably take pretty long. From the beginning of Crystal you didn't even have to specify the type of an array. This worked: `arr = []` but it was super slow! IIRC it took around 30 seconds to compile because Crystal of course has to type inference every type that might be pushed into that array! ⏎ So you still have to specify
<FromGitter> ... *some* types. But probably still way less than in other compiled languages.
rohitpaulk has quit [Ping timeout: 244 seconds]
non-aristotelian has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
<FromGitter> <DanilaFe> 30 seconds, darn
<FromGitter> <DanilaFe> I got to Crystal after this was changed
jemc has quit [Ping timeout: 240 seconds]
<FromGitter> <r00ster91> why having this alias? https://github.com/crystal-lang/crystal/blob/c9d1eef8fde5c7a03a029d64c8483ed7b4f2fe86/src/time.cr#L360 ⏎ shouldn't there be rather only Time.now?
jemc has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
Vexatos has quit [Remote host closed the connection]
Vexatos has joined #crystal-lang
<FromGitter> <bigeasy> Is Crystal written in Crystal?
<FromGitter> <vladfaust> Almost, yes
<FromGitter> <bigeasy> What bits are not Crystal and what language are they written in?
<FromGitter> <bigeasy> I'm poking through the source, so if you could suggest a directory to look in, that would be appreciated.
<FromGitter> <bigeasy> `/src/llvm/ext/llvm_ext.cc` is all I could find.
<FromGitter> <bigeasy> So, that means it's almost entirely built by itself. Neato.
<FromGitter> <j8r> the parts not written in Crystal can be due to lower level stuff that Crystal depends: LLVM is written in C++, Assembly to interact with processors.
<FromGitter> <kingsleyh> hey - can anyone give me some pointers on how I should represent this struct in Crystal
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c0c560233d9e11991a153b4]
<FromGitter> <kingsleyh> I don't understand what this C code is doing exactly
<FromGitter> <kingsleyh> my guess would be the struct takes 2 inputs - the pkey and the key - and then get0 takes the pkey and returns the pkey? and get1 takes the pkey and returns the key?
mps has joined #crystal-lang
<FromGitter> <girng> @delef i believe because classes need to know the instant variable types before initializing them