<FromGitter>
<doughsay> Sorry guys! ^ RE the above: apparently you're not allowed to do that without an initialized gl context, so... mystery solved. It works just fine with a properly initialized window.
Dreamer3 has joined #crystal-lang
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 260 seconds]
unshadow has joined #crystal-lang
unshadow has quit [Client Quit]
unshadow has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Client Quit]
nobilik has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest71914
Guest71914 has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
hightower2 has joined #crystal-lang
unshadow has quit [Quit: leaving]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Raimondi has quit [Ping timeout: 268 seconds]
Raimondi has joined #crystal-lang
Dreamer3 has quit [Quit: Computer has gone to sleep.]
Dreamer3 has joined #crystal-lang
bjz has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<schoening> Quite a lot of inconsistency with array method names... "!" at the end of a method indicates changes to self instead of returning a new instance, correct? But in practice it's only applied occasionally..
<Yxhuvud>
no, it is more like it implies danger ahead, but it not applied when the name itself implies that. (such as #delete)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
<Yxhuvud>
or at least htat is how it works in ruby. I don't know if crystal have choosen a diffent thinking there.
<FromGitter>
<schoening> Ok. I just misunderstood then
<FromGitter>
<schoening> Altho "danger" is hard to define. Any mutation is seen as dangerous by some: o
<FromGitter>
<schoening> :smile: *
<oprypin>
danger when it's not obvious
<oprypin>
in practice i see ! applied when a non-! counterpart makes sense
<hightower2>
Hey could you help me with this one: I have array like [ 1, 2, [:a, :b], [:c, :d]], and I would like the final outcome to be an "expanded" array with contents [ [1,2,:a,:c], [1,2,:b,:c], [1,2,a:,:d], [1,2,:b,:d] ]. But I have a hard time envisioning how to do this properly/efficiently
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<Thau> Hello, there, people! I have a quick question about JSON.mapping. How does one initialize an object to serialize it? It seems the only ways to initialize are giving some previous json either as a String or as a PullParser, but I'd like to initialize an object with my own values and then serialize it as JSON. Is mapping not the right way here?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hightower2>
Hey, I noticed a peculiarity in behavior of def something= (one, two) . It is displayed in https://play.crystal-lang.org/#/r/2aby . Is this a known/expected behavior or parser bug?
<hightower2>
oprypin, yeah, in my context the issue is I don't always want to be saying x.mymethod= {1,false} . I would like the second arg to have a default value
<oprypin>
hightower2, i sent you the link, it addresses this problem differently
Nouv has joined #crystal-lang
Nouv has quit [Read error: Connection reset by peer]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<hightower2>
Let' say in general I have array of one type of values, and need to convert it to another type. (E.g. if I have [:a,:b,:c] and I want to convert it to [1,2,3]). Is there a better way than creating a new array and calling #push on it for every converted/transformed value?
Nouv has joined #crystal-lang
<oprypin>
hightower2, well that's literally what `map` does
<hightower2>
oprypin, oh lol, right, but I was thinking about avoiding a separate array. Like, changing the type in runtime
Nouv has quit [Read error: Connection reset by peer]
<oprypin>
hightower2, cannot do that
<oprypin>
well you can hack it in an unsafe way, take a memory region and say, actually tthese are numbers
<hightower2>
Good point about map though, I used each/push in one instance as if I forgot about map :)
<oprypin>
>> a = [:a, :b, :c]; pointerof(a).as(Array(Int32)*).value
<Papierkorb>
$WIDTH is unreliable, the only reliable way would be using ioctl(), or using ANSI escape sequences
<hightower2>
Right, sure
hightower3 has joined #crystal-lang
<Papierkorb>
hightower3: When you register your nick (`hightower`), you can always use it, including after connection drops, and don't have to resort nicks counting-up
<Nouv>
Papierkorb: Hey I'm back with the dumb questions!
<Nouv>
Papierkorb: Does Crystal emit LLVM IR (the human readable kind) or does it use the LLVM c api?
<hightower3>
Papierkorb, sure, hightower2 is my default one :) But I don't care, I've just set my IRC client to automatically try 2, 3, 4 etc. if taken :)
<Papierkorb>
hightower3: well responding to the right nick is much harder
<hightower3>
True, will fix, thanks
<Papierkorb>
Nouv: it wraps the C API, in the crystal project it's in `src/llvm`. Meaning, that by doing `require "llvm"` in your own project, you can use it too
<Nouv>
Papierkorb: Ah
hightower2 has quit [Ping timeout: 260 seconds]
<Nouv>
Papierkorb: Do compilers always use the api, or do some emit the human readable IR code?
<Papierkorb>
Nouv: No idea if all use the API, but they should. The IR is meant to be read, but not written
<Nouv>
Fair
greengriminal has quit [Quit: This computer has gone to sleep]
<Nouv>
Papierkorb: So the compiler uses the LLVM API to create the LLVM IR, which is then assembled, and linked with libc and libllvm?
<Papierkorb>
The compiler uses the LLVM API, which represents it somehow internally ("you don't care how"), but you can also ask it to represent it as IR for you to display. The rest is correct though, as long the built program requires libllvm. If you don't, it won't be there.
<Nouv>
Papierkorb: Okay, thank you!
<Nouv>
Papierkorb: Does Crystal use llvm-gcc for linking?
<Papierkorb>
Nouv: Any data can be represented differently, but equal in value. Consider the number 10 in decimal, but you can also represent it as A in hex. Their representation is different, but the value is the same. LLVM most likely has an internal representation consisting of tons of C++ structs and classes, not LLVM bitcode or IR. But you can represent ("transform") those back and forth easily, as all are equal in value, there's no loss of
<Papierkorb>
precision.
<Papierkorb>
Nouv: No, Crystal really calls out to `gcc` iirc
<Nouv>
Ah that's a good explanation, thanks
Nouv has quit [Quit: Nouv]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
A124 has quit [Ping timeout: 248 seconds]
<hightower3>
What's a good way to trim string to fewer characters? E.g. if it's #size==80 and I would trim it to 60?
bjz has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4659: Parser: correct to lex the part of keyword in macro (master...fix/crystal/lex-part-of-keyword-in-macro) https://git.io/vQ05i
A124 has joined #crystal-lang
onionhammer has joined #crystal-lang
thews has joined #crystal-lang
onionhammer1 has quit [Ping timeout: 248 seconds]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
rohitpaulk has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Groogy has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #4660: Fix a typo of the context name of asm options (master...fix/crystal/parse-asm-options-string) https://git.io/vQ0bi
<Groogy>
Hey so I'm starting to play around with Crystal and while sublime works well and all I want to try out VS Code which I've never used before and was wondering which plugin people recommend of the three?
<Groogy>
Only one of the three has a readme page on github that actually tries to sell it and not much to speak of for feature brakdowns :/
<Groogy>
haha think that was the one I mentioned as "the only one trying to sell itself"
<FromGitter>
<sdogruyol> lol
<FromGitter>
<sdogruyol> a good readme is a must
<Groogy>
eaxactly, howelse will I know if it is good or not ;D
<Groogy>
anyway thanks
<FromGitter>
<sdogruyol> may i ask where did you discover Crystal @groogy?
<Groogy>
personal development time at work, kind of ish. I enjoy languages like Ruby and I love figuring out how languages and somehow stumbled upon this
<Groogy>
what peeked my interest is what looked like black magic but the type unions
<FromGitter>
<sdogruyol> oh yeah, union types are the best
<Groogy>
Was easier to think about when I just thought off every single functiob/class as a template in c++
<FromGitter>
<sdogruyol> it actually made me love types
<Groogy>
It's a cool approach on merging duck typing and static typing
<FromGitter>
<sdogruyol> yeah
<FromGitter>
<sdogruyol> 2 years of Crystal and i still think that union types are really cool
<FromGitter>
<sdogruyol> always impresses me
<Groogy>
Oh it's that old already?, or well I guess for as languages goes that's pretty young
<FromGitter>
<sdogruyol> it's still not yet 5 years old
<FromGitter>
<sdogruyol> so it's pretty young
<FromGitter>
<sdogruyol> with a great potential :)
<Groogy>
hmm weird, it seems like it is further ahead in development than D in some areas
<Groogy>
and think D is way older
<Groogy>
though then again I am just starting out so what do I know
<Groogy>
impression wise that is
<FromGitter>
<sdogruyol> yeah, you are right
greengriminal has joined #crystal-lang
<FromGitter>
<sdogruyol> actually it feels really stable and actually not many breaking change
<FromGitter>
<sdogruyol> i remember Rust back in the day :P
<Groogy>
uh I remember long time ago someone tried to get me to try rust
<Groogy>
I mean some concepts were interesting but overall it really didn't sit well with me
<FromGitter>
<sdogruyol> it's hard
<FromGitter>
<sdogruyol> it has some novel ideas but for me it's overkill
<FromGitter>
<sdogruyol> on the other hand Crystal is the opposite. It's really simple and easy to get productive from day 1 (day 0 if you've used Ruby before)
<Groogy>
yeah though for me I'll have to wait until I finish my reinstall of archlinux at home. Until then I'll just use my archlinux at work
<Groogy>
so looking forward for when windows works ^^ (for now I am trying it in the ubuntu bash)
<FromGitter>
<sdogruyol> cool
<FromGitter>
<sdogruyol> we got some efforts going on Windows support
<Groogy>
also weirdly enough, being able to just having ability to do "remove this specific piece of code in release build" was somewthing I missed in Ruby
<FromGitter>
<sdogruyol> --release for the win :)
<Groogy>
Yeah but like, let's say in Ruby you have tons of logging that you donẗ want enabled in release/production. There was no way as far as I remember any way to physically take that code out
<Groogy>
like you can with crystal and macros
greengriminal has quit [Quit: Leaving]
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter>
<straight-shoota> Papierkorb, Nouv: Crystal does not use `gcc` directly but whatever `cc` or `CC` points to
<Groogy>
Hmm I get my test app to link with a shared library but trying to run the application it can't find the so file :/
<Groogy>
weird
<Groogy>
might just be an "ubuntu on windows" thing though I guess
<Groogy>
ah lol okay nvm, it just installs with the paths setup wrong I guess, fixing that fixed it
Nouv has joined #crystal-lang
Renich has joined #crystal-lang
Renich has quit [Ping timeout: 255 seconds]
<FromGitter>
<sdogruyol> @groogy yup, paths are important
Renich has joined #crystal-lang
<Renich>
I just learned that HTTP::params.from_hash was renamed to HTTP::params.encode. It caught me off guard
<FromGitter>
<sdogruyol> ugh, that's a bummer
<Renich>
well, good thing it was just a rename
<FromGitter>
<sdogruyol> no changelog for that?
<Renich>
sdogruyol: yes, the changelog mentions it
<FromGitter>
<sdogruyol> ah okay then
<FromGitter>
<sdogruyol> i've never used that method before
qard has joined #crystal-lang
<qard>
What's the best way to turn an IO into an array of UInt32?
<Papierkorb>
qard: That doesn't make much sense. do you want to read from the IO?
<qard>
I have a file that is a serialized sequence of UInt32 values, so I need to turn that into an array.
red_menace has left #crystal-lang ["bye bye..."]
<Papierkorb>
qard: You want to read the file..?
<qard>
Well, more accurately, it's the content of an XML element in an XML file.
<qard>
It's base64-encoded and possibly gzip or zlib compressed. I can deal with that, then I have an IO that I need to turn into an array of UInt32 somehow.
<Papierkorb>
qard: You can not "turn an IO into an array". You can read from an IO.
<Papierkorb>
qard: You can use IO#read_bytes(UInt32) to read a single integer, which you can then throw into an array or whatever you need
<qard>
I know I need to read it somehow. I'm just trying to figure out what would be the process of reading from it and converting it to a UInt32 somehow.
hightower2 has joined #crystal-lang
<qard>
Oh, read_bytes is what I was looking for. Missed that somehow. Just saw read_byte, which returns a UInt8? result.
hightower3 has quit [Ping timeout: 248 seconds]
<FromGitter>
<sdogruyol> @papierkorb how's your lineage server going
<Papierkorb>
sdogruyol, you meant my WoW PoC? Dropped it after getting out of the project what I wanted. You may be referring to someone else who was talking about a MMORPG server clone too months ago .. May have been Lineage even
<Renich>
guys, let's say I want to stop execution at a certain point. Can I use exit? Or should I use self.exit?
<qard>
Hmm...it'd be nice if there was a way to do that without a rescue, but I guess EOFError works.
<oprypin>
qard, IO#read is the thing i was thinking about, and it's the way to do that (not quite that) without a rescue https://crystal-lang.org/api/master/IO.html#read%28slice%3ABytes%29-instance-method
<oprypin>
i mean if you're reading binary data structures, you are supposed to know the sizes of everything in advance
<oprypin>
in that case eof is indeed something you dont expect and should be an error
<qard>
I *do* know the size of the input. The problem though is that I need UInt32, not UInt8.
<qard>
So I'm using read_bytes(Uint32) rather than read_byte.
<qard>
Kind of weird that read_byte returns a nilable, but read_bytes doesn't.
<Papierkorb>
qard: Then calculate the expected amount of integers beforehand. Also make sure that the size of data is actually divisable by sizeof(UInt32).
<Renich>
straight-shoota: thanks!
<hightower2>
How do I create a shard and publish on crystalshards.xyz ?
<Renich>
if I run create order, it works, if I run remove order, it works fine as well... If I try it in sequence, it doesn't even run and it fails to right before running; at compile time
<Groogy>
Hey so after I have downloaded a shard, what is the correct way to include it in a file, let's say my main file?
<Groogy>
will shards just automatically add include path to it?
<FromGitter>
<bararchy> You need to configure it in your shards.yml file and call `crystal deps`
<FromGitter>
<mverzilli> @elorest we're aiming at fixing the package issues early in the week (Mon/Tue/Wed)
<crystal-gh>
[crystal] mverzilli pushed 1 new commit to master: https://git.io/vQEtK
<crystal-gh>
crystal/master dcf8a03 TSUYUSATO Kitsune: WebSocket: should compare 'Upgrade' header value with case insensitive (#4617)...
<hightower2>
Groogy, yes, you need to add it to shards.yml, which I assume you did, since you said "I have downloaded a shard". After adding to that file, you would run "shards install". This would install the shard inside .shards/ in project directory. And in your code, you would say "require "...shard name..."", without prefixing it with ./ or some path, just the shard name.
<Groogy>
nice! last part was what I was looking for
<Groogy>
thanks!
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<drosehn> The goal is for the end of this year. Personally, I suspect that is a little ambitious. Note that I do zero work on crystal, so I'm just giving you my own personal guess which is based on approximately zero knowledge.
<FromGitter>
<johnjansen> can you isolate the error
<FromGitter>
<renich> Try reading only miners.cr and test_order_delete.cr...
<FromGitter>
<johnjansen> whats the exact error you get
<FromGitter>
<renich> or, I'll see if I can isolate the error... taking the relevant methods ... sorry, I know it's a mess. I don't know if I can get it to compile, work since the API I am consuming requires auth and stuff
<FromGitter>
<johnjansen> what is the error and we will try to skip all the rest
<FromGitter>
<renich> as I thought it, you are supposed to be able to pass order_response to remove_order and that would do. But I have this really mysterious compile-time error... No idea of what's happening.
<FromGitter>
<johnjansen> so `order_response` in `nil`
<FromGitter>
<johnjansen> right?
<FromGitter>
<johnjansen> what get dumped from `pp order_response`
<FromGitter>
<johnjansen> on 59 of test
<FromGitter>
<renich> well, I don't think it is. Check this typeof pp of it: ⏎ ⏎ ` `` ⏎ typeof(order_with_id) # => Hash(String, Float64 | Int32 | String) ⏎ order_response # => {"location" => 0, ... [https://gitter.im/crystal-lang/crystal?at=595987bbbf7e6af22c98cbd0]
<FromGitter>
<renich> whoops, sorry
<FromGitter>
<johnjansen> you need to dump the return from `nh[:rw].create_order(order)`