ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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
<ben___> Channel is only to communicate a typed data to a receiving channel (same channel but another fiber), so a reading fiber can do next thing (like 4 fibers are calculating image manipulation or waiting for DB or HDD and so on), but a request should be a request on this one fiber. Channels do not concrete things like puts... They just send special information, where useful
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 248 seconds]
p0p0pr37_ is now known as p0p0pr37
<FromGitter> <Blacksmoke16> gotcha
faustinoaq has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Liothen has quit [Ping timeout: 260 seconds]
Liothen has joined #crystal-lang
snsei has joined #crystal-lang
sherjilozair has joined #crystal-lang
Guest9089 is now known as Cyrus
snsei has quit [Ping timeout: 268 seconds]
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
Raimondi has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
snsei has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
snsei has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
tankf33der has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
sherjilozair has quit [Remote host closed the connection]
sherjilozair has joined #crystal-lang
sherjilozair has quit [Remote host closed the connection]
sherjilozair has joined #crystal-lang
sherjilozair has quit [Client Quit]
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> ^^ Oh, Microsoft own a lot of good names 😅
ua has joined #crystal-lang
ua_ has quit [Ping timeout: 248 seconds]
<FromGitter> <codenoid> > > puts "hello"
_whitelogger has joined #crystal-lang
<FromGitter> <bararchy> @faustinoaq They will soon add github to that list
<FromGitter> <bararchy> :(
<FromGitter> <bararchy> btw, shards support gitlab ?
<faustinoaq> Oh :/
<faustinoaq> @barachy What about canonical?
<faustinoaq> s/@barachy/ @bararchy / ^^
<FromGitter> <bararchy> They don't own them they colaborate
<FromGitter> <bararchy> github is going to be a different story
<FromGitter> <bararchy> they gonna buy them
<FromGitter> <bararchy> which means it becomes a full Microsoft platform
<Yxhuvud> not necessarily.
<Yxhuvud> but it will probably mean more integration with microsoft products and possibly more focus on enterprise customers.
rohitpaulk has quit [Ping timeout: 256 seconds]
<FromGitter> <bararchy> It also means I need to trust Microsoft with my private repo code
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> it's a conflict on interest, github only makes github, it's not a software house but a platform. ⏎ Microsoft on the other hand is into software development, and it's going to hold alot of closed source code of other people in it's hands
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<ben___> Thank them for VS Code
<FromGitter> <bararchy> VS Code is good, so is sublime and vim and emacs and... ⏎ what's does code editor have to do with github purchuse discussion though?
duane has joined #crystal-lang
duane has quit [Ping timeout: 240 seconds]
<ben___> Microsoft is going to change cause they know about developers and contributors. However, thats all a little bit of risc
<ben___> Thanks for sublime?? I paid 50 Euro for my first license
<FromGitter> <bararchy> Oh, I didn't pay, using sublime2
<ben___> Ok, I want to pay for this, but, in this discuss - not
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
That_Guy_Anon has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
Groogy has quit [Quit: WeeChat 2.1]
snsei has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
<ben___> @Blacksmoke16 can't interpret gotcha ? ;-) are you going better with channels?
_whitelogger has joined #crystal-lang
rohitpaulk has joined #crystal-lang
pabs has quit [Ping timeout: 256 seconds]
pabs has joined #crystal-lang
TCZ has joined #crystal-lang
tzekid has joined #crystal-lang
tzekid has left #crystal-lang [#crystal-lang]
rohitpaulk has quit [Ping timeout: 256 seconds]
bazaar has quit [Ping timeout: 256 seconds]
bazaar has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
pabs has quit [Ping timeout: 265 seconds]
pabs has joined #crystal-lang
TCZ has quit [Quit: Leaving]
TCZ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <CaDs> Back from the RubyKaigi. It was interesting that a lot of teams and people are currently working on different ways to "compile" ruby and to enable (to some extend) type checking. ⏎ ⏎ And while I was listening to their progress and their difficulties achieving this I could not avoid thinking (and asking to some committers) about the way Crystal handles all those things in an efficient and elegant way. ⏎ ⏎
<FromGitter> ... Of course the compiler could be faster, and still there are lots of things Crystal needs to "get right", but for being such a young language I think is in a very nice position. ... [https://gitter.im/crystal-lang/crystal?at=5b13d743160c567d16fc9df7]
<FromGitter> <bararchy> 🎉
<FromGitter> <fgimian> +1
<FromGitter> <bararchy> same feeling when I see truffle-ruby all over
Raimondi has joined #crystal-lang
<FromGitter> <CaDs> trufle-ruby is gonna be big
<FromGitter> <CaDs> the demo was amazing
<FromGitter> <CaDs> the only thing I'm not so sure about is Oracle's licensing strategy
<FromGitter> <CaDs> anyway, it was great
<FromGitter> <fidellr> hi, i'm coming from go and i want to try how fast performance and great dev experience that crystal has, could anyone point me where should i start to learn from ? thx
rohitpaulk has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <fgimian> @fidellr I found the docs extremely handy, there's a really nice tutorial on the website.
<FromGitter> <fgimian> https://crystal-lang.org/docs/
<FromGitter> <fgimian> this one
<FromGitter> <fgimian> It covers most areas of the language with nice examples and easy to read information.
<FromGitter> <bararchy> @fidellr Good luck on your journy :)
<FromGitter> <fidellr> yes i read that already but not all of it, i can't see any tour/tutorial like go, can you point me with a specific link ? @fgimian , thanks a lot btw @fgimian @bararchy 😃
<FromGitter> <fgimian> I would start on this page https://crystal-lang.org/docs/overview/ :)
<FromGitter> <fgimian> Actually, perhaps this page -> https://crystal-lang.org/docs/using_the_compiler/
<FromGitter> <fgimian> and then just hit the arrow keys on your keyboard to go through the sections
<FromGitter> <fgimian> To be honest, one of the things I LOVE about Crystal is that almost the entire source code is written in Crystal
<FromGitter> <fgimian> so one of the best things I did while learning was clone the Crystal GitHub repository and use that as a good learning reference
<FromGitter> <fidellr> hmm doesn't seems a tutorial to me, the overview and using_the_compiler pages just a spoiler of crystal syntaxes and cli usage
<FromGitter> <fidellr> https://tour.golang.org/ for example
<FromGitter> <fgimian> I do see your point yeah. I'm personally not aware of anything that's exactly like that Go tutorial in Crystal land. The pages I mentioned introduce you to all language features one at a time.
<FromGitter> <fgimian> You did hit the > arrow and go through the other pages right?
<FromGitter> <fgimian> there's a lot in there
<FromGitter> <fidellr> yeah i can see that, but some of the syntax is not explained for example the usage of `::`
<FromGitter> <fidellr> or double colons
<FromGitter> <fidellr> yes
rohitpaulk has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <fgimian> I see your point, I'm not aware of anything more extensive than the docs I linked; but many things that Crystal does are similar to Ruby.
<FromGitter> <fidellr> btw i'm not from ruby land, so sorry for the stupid questions because it 's unfamiliar for me
<FromGitter> <fgimian> nah not at all, I should tell you that I'm new to the language myself and also not a Ruby guy
<FromGitter> <fgimian> but I did find Ruby docs and answers very helpful while I was learning Crystal
<FromGitter> <fgimian> perhaps the more experienced guys here can point you in a better direction
<FromGitter> <fgimian> what language are you coming from?
<FromGitter> <fidellr> i see, well i came from c++, js, go and a bit rust, but i do a lot in go, js and c++, so the ruby syntax seems odd to me lol, how bout you btw?
<FromGitter> <fidellr> i just shocked when i saw the benchmarks of crystal, so i came here 😄
<FromGitter> <fgimian> yeah, it's pretty crazy
<FromGitter> <fgimian> I'm coming from Python but also started in C++
<FromGitter> <fgimian> the import system in Ruby / Crystal reminds me of C++
<FromGitter> <fgimian> modules are like namespaces
<FromGitter> <fgimian> require is like #include
<FromGitter> <fgimian> :)
<FromGitter> <fgimian> I'm afraid I have to get to bed
<FromGitter> <fgimian> all the best and have fun
That_Guy_Anon has joined #crystal-lang
<FromGitter> <bararchy> @fidellr I would suggest trying to create a small project, like calculator etc.. And then look at what you want to do at each step and find in the docs.
<FromGitter> <bararchy> Apart from that, searching for 'calculator in ruby' will probably give you a working crystal example
<FromGitter> <fidellr> ahh i can see that, thanks a lot btw @fgimian , right i have to try it and read the docs for solving the solutions, thanks @bararchy
<FromGitter> <Grabli66> Release? :)
TCZ has quit [Quit: Leaving]
<FromGitter> <bararchy> @Grabli66 still waiting haha
<FromGitter> <fidellr> @bararchy i'll look into it after dinner, thanks!
<FromGitter> <bararchy> And soo we will have https://www.packtpub.com/application-development/learning-crystal-programming which @sdogruyol is writing which should arive until end of June
<FromGitter> <bararchy> anyway, have a nice dinner, let us know if you need anything along the way
<FromGitter> <fidellr> wow, thanks man! you too..
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <Blacksmoke16> am getting there yea
<FromGitter> <fidellr> hi, is this a bug or something that i missed ? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b13fa38edd06f7d1506f8a0]
<FromGitter> <fidellr> the first salute is printing noway instead of fidel, it should print fidel because i changed it after i puts/print it, why is this happened?
<FromGitter> <fidellr> btw it should print `Hello #{name}` but it only print the @name prefixed only
tankf33der has left #crystal-lang [#crystal-lang]
<FromGitter> <bararchy> Ok, so, the first "why it prints `noway` is because of IO race condition. ⏎ you can do ⏎ ⏎ ```def salute() ⏎ puts "Hello #{@name}" ⏎ STDOUT.flush ⏎ @name = "noway" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b13fb83f9f2e56cf238e50e]
<FromGitter> <fidellr> why should i flush it ? :/
<FromGitter> <fidellr> instead of just redefined with another value
<FromGitter> <fidellr> btw it still logged the same result
<FromGitter> <bararchy> I'll tell you why, the `@` means an instance var, this means that it changes all over your class. ⏎ ⏎ if you would do for example ⏎ ⏎ ```name = @name ⏎ puts "Hello #{name}"``` ... [https://gitter.im/crystal-lang/crystal?at=5b13fbfd352b9e1a4b559f67]
<FromGitter> <bararchy> hm...
<FromGitter> <bararchy> let me see
<FromGitter> <bararchy> For me it shows ⏎ ⏎ ```Hello Fidel ⏎ Hello noway ⏎ Hello noway ⏎ ``` [https://gitter.im/crystal-lang/crystal?at=5b13fc41160c567d16fcfd63]
<FromGitter> <fidellr> hmm seems weird in me -_-, this are my code ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b13fc6cf9f2e56cf238e7b0]
<FromGitter> <fidellr> is it same like yours?
<FromGitter> <bararchy> I think you might be confused because of the crystal play output, please do `puts g.salute` etc..
<FromGitter> <bararchy> also, seems the STDOUT is not needed, I confused you too, sorry
<FromGitter> <bararchy> try saving the code into a file, and just run it with ⏎ `crystal greeter.cr`
<FromGitter> <fidellr> ahh yes the right square is showing the types only but not the output, sorry for confusing you , thanks!
<FromGitter> <bararchy> np, happy to help
<FromGitter> <fidellr> i should look into the output panel of crystal help,
<FromGitter> <bararchy> the right one shows the `return type` which is the `"noway" : String`
<FromGitter> <fidellr> yes, sorry for the mistakes
<FromGitter> <bararchy> as it's the last thing in the salute method
TCZ has joined #crystal-lang
<FromGitter> <fidellr> got it
<FromGitter> <bararchy> no no it's all good. ⏎ Some people are not used to it, in Ruby and Crystal each method (def...) returns the last type that was used, even when not using explicit return
<FromGitter> <bararchy> it can be a cool thing for stuff like ⏎ ⏎ ```def equal?(a,b) ⏎ a == b ⏎ end``` ⏎ ⏎ This will return a Bool [https://gitter.im/crystal-lang/crystal?at=5b13fda0b6eece791dd672e8]
<FromGitter> <fidellr> i see, but that `?` mark, is it needed to be returned bool?
<FromGitter> <bararchy> no, just syntax sugar :)
<FromGitter> <fidellr> ahh alright2, thanks again!
<FromGitter> <bararchy> and it's a Crystal idiom ⏎ ⏎ as in ⏎ ⏎ ```# Crystal preffers this ⏎ equal?() ⏎ # and not this ⏎ is_equal()``` [https://gitter.im/crystal-lang/crystal?at=5b13fec022a05f5e71f91a5b]
<FromGitter> <bararchy> but it's really just languge idioms
<FromGitter> <bararchy> both will work ofc
<FromGitter> <fidellr> ahh i see, btw is crystal has function could return multiple values feature? just asking..
<FromGitter> <bararchy> btw, in Crystal you can `force` the return type to be something specific by using ⏎ ⏎ ```def equal?(a,b) : Bool ⏎ a == b ⏎ end``` ⏎ ⏎ This will tell the compiler to expect and verify that this method returns a Bool, else it will thorw a compile time error [https://gitter.im/crystal-lang/crystal?at=5b13ff2a22a05f5e71f91b4e]
<FromGitter> <fidellr> wow same like go
<FromGitter> <bararchy> @fidellr What do you mean? like multiple values as in array ? or multiple types ?
<FromGitter> <bararchy> ```def return_random : Int32 | String ⏎ rand > 0.5 ? "Yey" : 0 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b13ff8eba1a351a68e79e8e]
<FromGitter> <bararchy> this will return randomly a string or Int32 :)
<FromGitter> <fidellr> in go we could return multiple values from a function, f.e: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b13fff0160c567d16fd09d3]
pabs has quit [Ping timeout: 245 seconds]
<FromGitter> <fidellr> so i could set conditional stmt for any error outside that function
<FromGitter> <bararchy> Not that I know of, but let's see if I maybe missing something :) ⏎ But you can do something similar with array ⏎ https://play.crystal-lang.org/#/r/47dz
<FromGitter> <bararchy> This shows it better https://play.crystal-lang.org/#/r/47e2
wrq has joined #crystal-lang
<FromGitter> <fidellr> wow i see, crystal could that too tho
<FromGitter> <bararchy> Oh, can also do without array, sorry https://play.crystal-lang.org/#/r/47e5
<FromGitter> <bararchy> just need to explicit call return
<FromGitter> <fidellr> seems like i keep dig into it for the long run
<FromGitter> <fidellr> i see
<FromGitter> <bararchy> :)
<FromGitter> <fidellr> got it, thanks man!
<FromGitter> <bararchy> np, enjoy
<FromGitter> <fidellr> 👍
pabs has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Nathanaelle has joined #crystal-lang
<FromGitter> <fidellr> btw what are your preferred editor for crystal? i use vscode but i can't see the definition of the code when i hovered it like other language does, even i used the extendsion, cmiiw
TCZ has quit [Quit: Leaving]
<FromGitter> <bararchy> @fidellr I use vscode too, to get better support install crystal extension and use `scry` , it adds lots of great things + support for hover etc..
<FromGitter> <bararchy> @faustinoaq can help out with it
<wrq> I don't get hover for everything, it tells me about properties and methods, but not about type inferences
<wrq> i just installed it just now
<FromGitter> <fidellr> how do setup scry to the lsp client? the vscode docs tell i should have package.json but in crystal we use shard.yml :/
<wrq> "crystal-lang.server": "/home/[redacted]/scry/bin/scry",
<wrq> in settings.json for vscode
<wrq> thats what I did, anyways.
rohitpaulk has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <fidellr> ah i see lemme try
<FromGitter> <fidellr> yes i don't get the hover too
<FromGitter> <fidellr> ah i got the definition when i hovered, you should turn the crystal-lang.hover to true
bbobb has joined #crystal-lang
<FromGitter> <fidellr> but it seems still unstable tho
<wrq> yeah I did, but I only get certain things. I'm sure it'll get better with time
<FromGitter> <fidellr> yes me too, i hope so
<FromGitter> <bararchy> Also make sure to install @faustinoaq vscode crystal extension
<FromGitter> <fidellr> i did
faustinoaq has quit [Ping timeout: 260 seconds]
faustinoaq has joined #crystal-lang
TCZ has joined #crystal-lang
TCZ has quit [Quit: Leaving]
<FromGitter> <fidellr> seems crystal beaten by rust when dealing databases :/ cmiiw ⏎ https://www.techempower.com/benchmarks/
<FromGitter> <bararchy> Oh, this is our biggest pitfall, the db driver is not really optimized, its being worked on.
<FromGitter> <bararchy> @fidellr keep in mind that Rust is all a non-GC language, which means it will always be faster, at least in theory
<FromGitter> <bararchy> But ofc it means memory management on dev side
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
<FromGitter> <fidellr> yes it make sense that rust more faster because of non-GC, but it still beaten by go with actix framework
<FromGitter> <fidellr> i still try to do a research for this case
<FromGitter> <bew> @bararchy note: it's better to use a tuple when returning multiple values from methods
<FromGitter> <bararchy> @bew yeha it makes more sense, I don't know why it didn't work for me without explicitly writing return
<FromGitter> <fidellr> i saw the right square on crystal-play it automatically return a tuple when we return two values, is really automated like that?
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <r00ster91> how can I execute the function/the actions that get normally executed when I press CTRL+C? Or can I be 100% sure that it will be just `exit` on all operating systems?
dragonkh has joined #crystal-lang
<dragonkh> hi - is there a Crystal version of PBKDF2 available?
alex`` has quit [Ping timeout: 248 seconds]
<dragonkh> but it seems it's not been implemented?
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
dragonkh has quit [Remote host closed the connection]
wuehlmaus has quit [Quit: Lost terminal]
return0e has quit [Ping timeout: 248 seconds]
Nathanaelle has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
Nathanaelle has joined #crystal-lang
return0e has joined #crystal-lang
dragonkh has joined #crystal-lang
<FromGitter> <Blacksmoke16> say i have JSON::Any data type
<FromGitter> <Blacksmoke16> and im passing it to a function
<FromGitter> <Blacksmoke16> the function determines if the param is an array or not
<FromGitter> <Blacksmoke16> if it is it creates and returns an array of self
<FromGitter> <Blacksmoke16> if its not an array it just returns a new instance of self
<FromGitter> <Blacksmoke16> but issue im having now is the return value of the function is a union of self | Array(self)
<FromGitter> <Blacksmoke16> can fix it by doing a .as(self) after i call it but is there a better way?
<FromGitter> <bararchy> You can use `exit` to do the same
Nathanaelle has quit [Read error: Connection reset by peer]
bbobb has quit [Quit: bbobb]
<FromGitter> <Blacksmoke16> are there docs on that somewhere?
Nathanaelle has joined #crystal-lang
<FromGitter> <bararchy> @Blacksmoke16 signal handeling ?
<FromGitter> <bararchy> I was answering @r00ster91
<FromGitter> <bararchy> Hope I didn't confuse you
<FromGitter> <Blacksmoke16> oh that would make more sense :p
<FromGitter> <bararchy> It seems gitters amazing android app cut off my response lol
<FromGitter> <bararchy> Its a really bad app
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/47gb
<FromGitter> <Blacksmoke16> example of my question, there a way to have it not union the types since they are mutually exclusive?
<FromGitter> <Blacksmoke16> without doing .as(type) after calling the function
<FromGitter> <benharri> bararchy: https://irc.gitter.im
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter> <bew> @Blacksmoke16 https://play.crystal-lang.org/#/r/47gm
<FromGitter> <r00ster91> @bararchy yes im getting key input with STDIN.raw and then CTRL+C doesnt gets automatically invoked. But I think I will just invoke `exit` then
<FromGitter> <bew> @Blacksmoke16 I don't understand what you mean by "there a way to have it not union the types since they are mutually exclusive?"
<oprypin> <@Blacksmoke16> say i have JSON::Any data type and im passing it to a function
<oprypin> you've already made a mistake there
That_Guy_Anon has joined #crystal-lang
<oprypin> you're supposed to get rid of JSON::Any as soon as possible, or even avoid it altogether
<FromGitter> <Blacksmoke16> thats why its being passed to the function, to resolve it into an object
<oprypin> i guess that makes sense
<FromGitter> <bew> @Blacksmoke16 checkout my example, there's no JSON::Any involved
<FromGitter> <Blacksmoke16> ideally i could use JSON.mapping but in this case i cannot :/
<FromGitter> <bew> why not
<oprypin> what is `as_a?` O_o
<FromGitter> <bew> I repost: https://play.crystal-lang.org/#/r/47gm @Blacksmoke16
<oprypin> oh
wrq has quit [Quit: Connection closed for inactivity]
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> kinda hard to explain, but is mainly due to there being another function that maps the input values to their correct types and sets them, based on a diff mapping syntax
<FromGitter> <Blacksmoke16> i tried using it, but it would require a good amount of work to get everything to work with both imo
<oprypin> could be still doable with mapping
<FromGitter> <Blacksmoke16> then would have to maintain two mappings of pretty much the same data
<oprypin> Blacksmoke16, so you're saying " the return value of the function is a union of self | Array(self)" but isn't that exactly what you wrote in your code?
<oprypin> if you want an array of one item, you can write `[new(args["foo"].as_s)]` not `new(args["foo"].as_s)`
Nathanaelle has joined #crystal-lang
<FromGitter> <Blacksmoke16> moreso the question was is there a cleaner way to have the function only return 1 type, vs doing .as(Foo) or .as(Array(Foo))
<FromGitter> <bew> what would be the type?
<FromGitter> <Blacksmoke16> whatever the class the function gets called on
<oprypin> Blacksmoke16, either you're missing a really obvious thing or you're forgetting to explain something
<FromGitter> <Blacksmoke16> yea you're right
<FromGitter> <Blacksmoke16> nvm sorry, yea that dumb
<FromGitter> <Blacksmoke16> wait, follow up question https://play.crystal-lang.org/#/r/47h1
<FromGitter> <Blacksmoke16> can you not specify the return value by calling .as(type) before returning the value?
<FromGitter> <Blacksmoke16> im thinking no because its still possible for the function to return both types
<oprypin> Blacksmoke16, dude... your function can return Array(Foo) or Foo. the function's return type is `Array(Foo) | Foo`. where is your surprise coming from?
<oprypin> before it was array or foo, now you say array.as(Array) or foo.as(Foo) but it's still the same union in the end
<FromGitter> <Blacksmoke16> right, yea idk why that was so confusing for me
<FromGitter> <Blacksmoke16> thanks
<oprypin> Blacksmoke16, see also https://play.crystal-lang.org/#/r/47h3
<oprypin> the runtime type is always precise, of course
<oprypin> but at compile time there's no way to make the type precise because it depends on the runtime value of the string
<FromGitter> <schoening> Could I get some help sending binary data over websockets? ⏎ In NodeJS I just send new Float32Array([1,2,3]) but I don't know the equivallent for crystal...
<FromGitter> <Blacksmoke16> yea that was my confusion i think
wuehlmaus has joined #crystal-lang
<FromGitter> <bew> @schoening what serialization are you using ? what do you mean exactly by "sending binary data" ?
<FromGitter> <schoening> I used NodeJS to send Float32Array buffers to the browser instead of JSON. Now I want to do the same with Crystal. Sorry if I can't explain myself correctly.
<oprypin> schoening, how can you receive those buffers in javascript? from what i've read there is no protocol support
<hightower2> Hey folks, am I doing something wrong or this is a compiler bug? https://play.crystal-lang.org/#/r/47ht
<FromGitter> <schoening> Well, I am far from as knowledgable as you guys, but I simply do this on the client side: ⏎ const data = new Float32Array( message.data );
<oprypin> please just show complete examples of: sending float array in js; receiving float array in js
<oprypin> oh that's your example, i see
<oprypin> schoening, i think you want https://crystal-lang.org/api/0.24.2/IO/ByteFormat.html
<FromGitter> <schoening> Thank you
<oprypin> schoening, `io = IO::Memory.new(); [1.23f32, 4.56f32].each do |x| io.write_bytes(x, IO::ByteFormat::LittleEndian); end; send io.to_slice`
<oprypin> maybe, i dunno
<oprypin> it would also be nice to see what bytes the js implementation expects and produces
<oprypin> but first you can just try the example, and ping me if it doesnt work
Nathanaelle has quit [Ping timeout: 245 seconds]
Nathanaelle has joined #crystal-lang
return0e has quit [Ping timeout: 245 seconds]
Nathanaelle has quit [Ping timeout: 276 seconds]
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
That_Guy_Anon has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 276 seconds]
alex`` has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Quit: Leaving]
return0e has joined #crystal-lang
<FromGitter> <fidellr> is there any recommendation architecture that well suited in crystal?
<FromGitter> <elorest> I’ve used it on ARM systems with linux, x86 systems with linux and OSX. We’ll suited for anything but windows basically.
<RX14> ugh, I really don't like microsoft buying github
<FromGitter> <elorest> <RX14> Wut? That sounds like an april fools joke or something?
<RX14> no lol
<FromGitter> <raydf> thx for gitlab to be a second alternative
<RX14> wsl, vscode, now buying github
<RX14> microsoft is taking a lot of control over the linux and open source ecosystem#
<FromGitter> <fidellr> i think gitlab too
<RX14> ??
<Vexatos> the thing about github is that it's trivial to switch to another host
<Vexatos> due to the nature of git :P
<RX14> microsoft has a history when they have control of ecosystems
<Vexatos> even issues can be easily reproduced
<RX14> Vexatos, nahh
<RX14> issues, pull requests are hard to migrate
<RX14> and putting your stuff on github has a major network effect
<RX14> as well as switching providers switches URLs
<FromGitter> <elorest> Gitlab is great, but all my OSS is on github.
<Vexatos> well you see
<Vexatos> about six years ago, everyone was using skype
<Vexatos> see what happened to that
<FromGitter> <fidellr> nah, gitlab is great when they have a dashboard like github did
<RX14> Vexatos, sure
<RX14> its possible to switch
<RX14> but it doesn't mean it's easy
<FromGitter> <bew> gitlab has a tool to migrate everything (issues/PR, milestones, ...)
<FromGitter> <raydf> the new gitlab is very close to all the features of Github
<RX14> i'd be supportive of crystal moving to self-hosted gitlab
<FromGitter> <bew> I re-discovering gitlab today, it's really really awesome
<RX14> its alright
<FromGitter> <bew> it's missing a full dark theme though
<FromGitter> <raydf> have you seen the issue board for complex projects
<FromGitter> <raydf> ?
<FromGitter> <raydf> is very nice
<FromGitter> <bew> yeah, they're doing a great job
<FromGitter> <fidellr> damn, gitlab feels trello/atlassian full featured now
alex`` has quit [Ping timeout: 265 seconds]
<FromGitter> <faultyserver> so I feel like I've run into this problem a lot and I can never remember the right way to handle it
<FromGitter> <faultyserver> but basically I have a large set of types that inherit from a `Node` class
<FromGitter> <faultyserver> and I want to make methods that accept some sub-union of those types
<FromGitter> <faultyserver> in this case: `Call | Const`
<FromGitter> <faultyserver> but it always gets expanded to `Node+`
<FromGitter> <bew> not anymore in next release!
<FromGitter> <faultyserver> is that properly getting fixed?
<FromGitter> <faultyserver> cause I feel like it was supposed to be fixed in 24.1 as well
<FromGitter> <faultyserver> either way, is there any nice way to deal with it now?
<FromGitter> <bew> it was not a bug
<FromGitter> <bew> I guess you could add a type restriction to the method?
<FromGitter> <faultyserver> I did
<FromGitter> <faultyserver> I put types on everything involved
<FromGitter> <faultyserver> and it still gets expanded
<FromGitter> <faultyserver> minimized, invalid sample of what I've got: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b14691699fa7f4c0640e67c]
<FromGitter> <faultyserver> I've solved this in the past by introducing intermediate types in the hierarchy, but that doesn't really work here (because the node types are semantically unrelated, they are just both valid in this case)
<FromGitter> <faultyserver> I guess the other solution is to use `[] of Call | Const` whenever I want to call the initializer
<FromGitter> <faultyserver> More generally, if that's *not* a bug, I'd like to understand what purpose the expansion really serves (other than being the Hindley-Milner "most generic type expression" thing)
<FromGitter> <bew> oh for that... yeah you need to be explicit for now, but this will be as you expect in next release (see: #6024)
<FromGitter> <faultyserver> cause in every case I've run into, when I write out a type union, I'm pretty explicitly only trying to accept the types I wrote out (and I guess subtypes of those types)
<DeBot> https://github.com/crystal-lang/crystal/pull/6024 (Don't automatically virtualize two types in the same hierarchy, unless one is deeper than the other)
<FromGitter> <faultyserver> awesome
<FromGitter> <faultyserver> glad to see that
<FromGitter> <bew> actually I'm not sure, your best bet is to actually try it on master
snsei has quit []
TCZ has joined #crystal-lang
<crystal-gh> [crystal] bew opened pull request #6159: Disallow negative enum flag values (master...disallow-negative-enum-flag-values) https://git.io/vhlV8