ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | 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
sz0 has joined #crystal-lang
<FromGitter> <codenoid> sadly, i was not in jakarta at that time, https://www.youtube.com/watch?v=ptUdnpz1w0A
<crystal-gh> [crystal] bcardiff opened pull request #5317: Allow less than expected digits when parsing time with decimals (master...feature/fewer-digits-time-parser) https://git.io/vFF7o
<FromGitter> <cyclecraze_twitter> ```code paste, see link```
vivus has quit [Quit: Leaving]
<FromGitter> <ezrast> You can at least do `p = Person.from_json "{}"`, no?
qard has joined #crystal-lang
<FromGitter> <edwardloveall> Hi all!
<FromGitter> <edwardloveall> I'm still a bit new to crystal
<FromGitter> <edwardloveall> really enjoying it, and I'm trying to figure out how to use `crystal play`
<FromGitter> <edwardloveall> I made a main.cr file and imported it into the playground, but it's saying `undefined constant Person`
<FromGitter> <edwardloveall> so I feel like maybe I'm not understanding how playgrounds work
<FromGitter> <edwardloveall> and I couldn't find any docs or tutorials on the website
<FromGitter> <edwardloveall> if anyone has any advice or a tutorial to link to, that would be super helpful!
<faustinoaq> @edwardloveall Try using work workbook section πŸ™‚
<FromGitter> <edwardloveall> I'll check that out, thanks!
<FromGitter> <ezrast> @edwardloveall Your example is compiling because there's a file named `main.cr` in Crystal's standard library. I'm not sure whether there's a way to require local files in the playground.
<FromGitter> <ezrast> That should read "Your example's first line is compiling..."
<FromGitter> <edwardloveall> ah ha
<FromGitter> <edwardloveall> okay
<FromGitter> <edwardloveall> i'll do some digging
<FromGitter> <edwardloveall> thanks for the that info
<FromGitter> <edwardloveall> mmm interesting. I did `Dir.current` and it listed the directory the file is in
<FromGitter> <edwardloveall> I renamed the file to `scratch.cr` and tried to require it and got
<FromGitter> <edwardloveall> > an't find file 'scratch.cr' relative to '.'
<FromGitter> <edwardloveall> so yup, exactly like you said
<FromGitter> <edwardloveall> ah I got it working in a workbook
<FromGitter> <edwardloveall> with `require "./playground/person.cr"`
<FromGitter> <edwardloveall> yup, works in normal playground too :D
<FromGitter> <edwardloveall> thanks all
thews has quit [Ping timeout: 248 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thews has joined #crystal-lang
thews has quit [Changing host]
thews has joined #crystal-lang
mbarbar has joined #crystal-lang
baweaver has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
mbarbar has quit [Ping timeout: 240 seconds]
<FromGitter> <HCLarsen> Hey everyone, in case you're curious, I just wrote my first crystal tutorial blog. Check it out if you want:
<FromGitter> <fridgerator> πŸ‘
<FromGitter> <codenoid> how i can convert ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ to crystal hash [https://gitter.im/crystal-lang/crystal?at=5a15073971ad3f873615bacf]
<FromGitter> <codenoid> puts ^ data ⏎ ⏎ ```[{"address" => "55291820428", "smd" => "foobar"}]``` [https://gitter.im/crystal-lang/crystal?at=5a1507eb71ad3f873615be6b]
<FromGitter> <johnjansen> @codenoid that union type is many things, but its not very convertable as it stands ...
<FromGitter> <codenoid> i just wanna do something like ⏎ ⏎ ```data.each { |v| p v["address"] }``` [https://gitter.im/crystal-lang/crystal?at=5a1508c2ba39a53f1acd7483]
<FromGitter> <johnjansen> the data you supplied is already an array of hashes, but the type implies something more comples
<FromGitter> <johnjansen> what you suggested is conceptually correct for the data you supplied, but then you dont need to convert it .. since its already a hash
<FromGitter> <johnjansen> https://carc.in/#/r/34ni
<FromGitter> <codenoid> `undefined method '[]' for BSON::Value` idk :/
<FromGitter> <johnjansen> thats what i was meaning … your union type is a mishmash of incompatible types
<FromGitter> <johnjansen> or at least types which dont all behave the same way
<FromGitter> <johnjansen> remove the outer `()` and look carefully at the types in the union ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a150b04614889d475ae8e2c]
<FromGitter> <johnjansen> and array of hashes OR this OR that OR something else OR any number of things OR Nil
<FromGitter> <johnjansen> not all even implement `each` ...
<FromGitter> <johnjansen> so on the surface right from the outset there is a problem
<FromGitter> <codenoid> okay, i just cast BSON type to string
<FromGitter> <codenoid> bson = `{"fa":"fwf"}` just like json, and i do JSON.parse
<FromGitter> <johnjansen> ok, you also have various number types, and regex and time to deal with …
<FromGitter> <johnjansen> also, the bson turns out a JSON::Any … so you just moved the issue
<FromGitter> <johnjansen> what are you actually trying to do?
<FromGitter> <johnjansen> more than of your types (in the union) might be deep data
<FromGitter> <johnjansen> ^one^
<FromGitter> <codenoid> thank @johnjansen ,i totally cast that type to only hash and string, πŸ‘
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
snsei has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
mbarbar has joined #crystal-lang
DTZUZU has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
snsei has quit [Remote host closed the connection]
claudiuinberlin has joined #crystal-lang
mark_66 has joined #crystal-lang
<Groogy> Morning! o/
<FromGitter> <unreadable> Morning all too
rohitpaulk has joined #crystal-lang
Papierkorb_ has joined #crystal-lang
<FromGitter> <Qwerp-Derp> oprypin: `Font.from_file` doesn't work with files outside of `src`, I'm trying to do `Font.from_file("../resources/FiraCode.ttf")` and it simply doesn't work
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<Papierkorb_> Paths are resolved at runtime of your program. Relative paths are always relative to the current working directory of your process.
<Papierkorb_> Qwerp-Derp
<FromGitter> <Qwerp-Derp> Ah, OK. Fixed the issue, thanks!
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<crystal-gh> [crystal] bew opened pull request #5318: Remove useless suffix condition (master...remove-useless-contition) https://git.io/vFbBs
<FromGitter> <Qwerp-Derp> Wait... is there a difference between going `./foo` in the command prompt and clicking on the executable `foo`?
<FromGitter> <Qwerp-Derp> `./foo` works fine, but when I click on the executable the program's file path references mess up
snsei has joined #crystal-lang
<Papierkorb_> That's up to your file browser.
<FromGitter> <Qwerp-Derp> Oh. After looking at an SO question, it turns out the working directory is my home directory when double-clicking using Finder.
<FromGitter> <Qwerp-Derp> How do I change this function so that it affects the relative directory of the executable instead, using the command line?
snsei has quit [Ping timeout: 252 seconds]
<Papierkorb_> `Dir.cd File.dirname(Process.executable_path.not_nil!)`
<Papierkorb_> Don't go around patching random methods. Either patch a single method which knows the root directory of assets (This is actually preferred), or if you know what you're doing, make the environment the expected environment
<FromGitter> <Qwerp-Derp> I just placed it in my main `mirrors.cr` file
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <bararchy> It's amazing that the Lexical scope issue is still here after so long :\
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
<Papierkorb_> RX14, could #5257 be merged until release of 0.24? Without the fix real-world code breaks on my end
<DeBot_> https://github.com/crystal-lang/crystal/pull/5257 (Make String#[] not read out-of-bounds if string ends in unicode char)
<RX14> ping it
<RX14> i approved it
<RX14> just need to remind the rest of the team that it's a security issue and must be merged
<Papierkorb_> kk
<FromGitter> <JonnyCodewalker> quick question: why does `(flags.index.nil? ? 0 : flags.index).times do` complain that `times` is not defined for nil doesnt the tenary if assure that it can not be nil?
<Papierkorb_> You're calling `flags.index` twice, the second call could return `nil` again
<FromGitter> <JonnyCodewalker> but i only call it a second time if it is not nil
<Papierkorb_> If you want *that* line to work, `(flags.index || 0).times` could work. But I'd actually prefer it to be rewritten in a fashion that gets a non-nil passed into, or set by a `if var =`
<Papierkorb_> No you call it twice.
<RX14> flags.index is a method
<RX14> it can returnj different things every time
<RX14> it probably doesn't
<RX14> but the compiler cannot prove that
<Papierkorb_> Consider this method: `def index; rand > 0.5 ? 123 : nil; end` Your check there calls this method twice, and thus is not sufficient to ensure its non-nil
<Papierkorb_> This method may look outlandish at first, but it's the worst-case scenario, and the compiler has to consider this scenario
<FromGitter> <JonnyCodewalker> aaaah. i misunderstood the shard i was using, yeah makes sense what you say
<FromGitter> <JonnyCodewalker> for some reason in my brain it was not a method but a variable.
<RX14> it's always a method in crystal
<FromGitter> <JonnyCodewalker> yeah, that was what i was not aware of, but thats is why i am trying out stuff to understand :D
<RX14> btw this logic also applies for @var and ::var instance/class variables because they can be changed by other threads inbetween the nil check and you using them
<RX14> oops
<RX14> @@var
<Papierkorb_> Sidenote, tenary operators aren't super common in Crystal. *Usually* using `x || y` suffices instead of doing `x ? x : y`
<RX14> ^
<FromGitter> <JonnyCodewalker> if it does that would be nice since it is more readable :)
<FromGitter> <JonnyCodewalker> thanks for the help
<Papierkorb_> RX14: Should I CC anyone into there
<Papierkorb_> ?
<RX14> all the core team are watching the repo
<RX14> pinging them doesn't actually do anyting extra
<Papierkorb_> good to know, I would've @-ed people at basically random
rohitpaulk has quit [Ping timeout: 246 seconds]
hightower2 has quit [Ping timeout: 240 seconds]
<travis-ci> crystal-lang/crystal#f311861 (master - Don't use `{{yield}}` outside a macro (#5307)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/305773658
<DeBot_> https://github.com/crystal-lang/crystal/pull/5307 (Don't use `{{yield}}` outside a macro)
rohitpaulk has joined #crystal-lang
<FromGitter> <extremety1989> @FromIRC can we do also nested tenary ?
<crystal-gh> [crystal] RX14 closed pull request #5314: Abstract LibGC usages. Enable none garbage collector. (master...core-abstract-garbage-collector) https://git.io/vFQrF
<FromGitter> <bararchy> Hm... seems like thin-lto just crashes
<FromGitter> <bararchy> when I try to build
snsei has joined #crystal-lang
<FromGitter> <bararchy> it says ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a15751cba39a53f1acfba7d]
rohitpaulk has quit [Ping timeout: 240 seconds]
sz0 has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> @extremety1989 did you tried?
<crystal-gh> [crystal] ysbaddaden closed pull request #5318: Remove useless suffix condition (master...remove-useless-contition) https://git.io/vFbBs
<FromGitter> <extremety1989> @bew only in javascript =)
<FromGitter> <codem4ster> Hi everybody. How can I get a stream from a url and write to a file with Crystal? I couldn't understand IO operations in Crystal well. Would you share an example please? :)
<travis-ci> crystal-lang/crystal#e687dee (master - Abstract LibGC usages & reenable none GC (#5314)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/305792412
<DeBot_> https://github.com/crystal-lang/crystal/pull/5314 (Abstract LibGC usages. Enable none garbage collector.)
<FromGitter> <bcardiff> @HCLarsen regarding, ⏎ ⏎ > https://hclarsenblog.wordpress.com/2017/11/22/working-with-command-line-arguments-in-crystal/ ⏎ ⏎ I like it. I like when the features are discoverd through usage like how you present multiline string literals. ... [https://gitter.im/crystal-lang/crystal?at=5a157af6ba39a53f1acfdac8]
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vFbyG
<crystal-gh> crystal/master f6a1fa1 Stefan Merettig: Make String#[] not read out-of-bounds if string ends in unicode char (#5257)...
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
<FromGitter> <sdzyba> does anyone know what's holding back the 0.24.1 release? the issue with LLVM? ⏎ the reason I'm asking is because it was mentioned that 0.24.0 should be considered as a release candidate, not the regular "stable" version
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> I guess they are waiting for more users to try it and see if there are "BIG" issues that might effect usability
<FromGitter> <bararchy> I'm using HEAD, and didn't see anything unusual (except thin-lto I mentiond above)
<travis-ci> crystal-lang/crystal#f6a1fa1 (master - Make String#[] not read out-of-bounds if string ends in unicode char (#5257)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/305808955
<DeBot_> https://github.com/crystal-lang/crystal/pull/5257 (Make String#[] not read out-of-bounds if string ends in unicode char)
<FromGitter> <DRVTiny> Hello, guys!
<FromGitter> <DRVTiny> Where to read about using inline assembler in Crystal?
<FromGitter> <DRVTiny> I know, this is some LLVM-related feature... Maybe Rust documentation can help me?
<FromGitter> <bew> it's not llvm-related
<FromGitter> <bew> from my understanding this is a part of the code that will be put as is by llvm, so you can write direct asm
<FromGitter> <DRVTiny> But why inline asm in Rust is very like Crystal's one
<FromGitter> <extremety1989> guys did someone used selfreferencing tables in POSTGRESSQL ?
<FromGitter> <DRVTiny> I dont know what to wrote after asm("code" : WHAT_IS_THIS1 :: WHAT_IS_THIS2)
<Papierkorb_> See the GCC notation, LLVM mirrors that and Crystal mirrors LLVMs
<FromGitter> <extremety1989> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a15947e540c78242d3679f6]
<FromGitter> <extremety1989> its a Message class
<FromGitter> <extremety1989> i want a json mapping
<FromGitter> <DRVTiny> Where to read, what does it mean: "{rcx}"(variable) ⏎ Is rcx==variable after that or rcx==address_off(variable)?
<FromGitter> <DRVTiny> What is the difference between "r", "=r" and etc.?
<FromGitter> <bew> @extremety1989 `id: {type: Int64, nilable: true}` can be written as `id: Int64?`
<FromGitter> <extremety1989> @bew yes, it works
<FromGitter> <DRVTiny> Can i use intel syntax instead of annoying AT&T?
<FromGitter> <extremety1989> @bew wait , sorry missunderstood
<FromGitter> <extremety1989> @bew havent tried it yet
<FromGitter> <extremety1989> @bew try it self =)
<FromGitter> <extremety1989> @DRVTiny zdorova ))
<FromGitter> <DRVTiny> @bew The problem is that there is no documnted anywhere, how to pass parameters to "asm" inlines and how to get results from it. Without this explanations, inline asm is totally useless feature.
<FromGitter> <DRVTiny> @extremety1989 Privet-hello :)
<FromGitter> <bew> @DRVTiny not sure it's exactly the same syntax, but I've found http://www.cs.virginia.edu/~clc5q/gcc-inline-asm.pdf
<FromGitter> <extremety1989> @DRVTiny vi s Rossii ?
<FromGitter> <DRVTiny> @extremety1989 Yes :)
<FromGitter> <DRVTiny> @bew Thank you very much, it seems, that is exactly what i looking for!
mbarbar has quit [Ping timeout: 268 seconds]
<FromGitter> <DRVTiny> Already printed this wonderful booklet to read during subway movements :)
snsei has joined #crystal-lang
<FromGitter> <bew> @DRVTiny and yes you can write in intel syntax (https://github.com/crystal-lang/crystal/blob/master/spec/compiler/formatter/formatter_spec.cr#L662)
<Papierkorb_> The fiber.cr also uses tons of inline assembly
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <bew> ah, page 15 in the pdf I linked: The general form of an asm call is `asm( β€œcode” : outputs : inputs : clobbers)`
<robacarp> given a method that receives splat args, is there a quick way to add one element to the named tuple from the splat, and then pass that named tuple on to another function?
<robacarp> I expected to be able to do something like: def a(**args); b(first: 1, **args); end
<FromGitter> <bew> it should work
<robacarp> perhaps I'm missing something then, the compiler gives "expected named argument, not **"
<FromGitter> <bew> ah yes, use `def a(*args, **named_args); b(*args, first: 1, **named_args); end`
<FromGitter> <bew> `*args` is to capture positional arguments
<FromGitter> <bew> and `**named_args` for named arguments
<robacarp> even if b doesn't have any positional arguments?
<FromGitter> <bew> if you're sure there's no positional args, you can omit it, yes
<robacarp> https://carc.in/#/r/34qm and https://carc.in/#/r/34qn , with and without the positional args
<FromGitter> <bew> weird that you can't use `**named_args` after a named arg.. nvm you can use https://carc.in/#/r/34qr
<robacarp> oh, ok. thats subtle! thanks
daemonwrangler is now known as derek-away
derek-away is now known as daemonwrangler
daemonwrangler is now known as derek-away
mark_66 has quit [Remote host closed the connection]
<FromGitter> <jwaldrip> What is the nodoc syntax for crystal?
<FromGitter> <sdogruyol> @jwaldrip it's really self-explanatory :P
<FromGitter> <jwaldrip> `# nodoc` ?
<robacarp> @jwaldrip `# :nodoc:`
<FromGitter> <jwaldrip> Got it! Thank you. So the same as rdoc's.
<FromGitter> <jwaldrip> thanks
derek-away is now known as daemonwrangler
<FromGitter> <extremety1989> is JSONB faster in postgres ? than using normal types ?
vivus has joined #crystal-lang
Papierkorb_ has quit [Quit: Konversation terminated!]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> @extremety1989 jsonb is fast. What's normal types though?
<FromGitter> <extremety1989> Ints Strigs
<FromGitter> <sdogruyol> that's not a direct comparison
<Papierkorb> JSONB and JSON are about their representation in the database, both are fast for different things
<FromGitter> <extremety1989> @sdogruyol oh okey
<FromGitter> <extremety1989> @FromIRC where can i get tutorials with jsonb and crystal ?
<Papierkorb> JSONB and JSON work the same regarding the API you access them
<Papierkorb> No idea how it works with Crystal.
<Papierkorb> Also, my name is in the < >, @FromIRC is a bot.
<FromGitter> <extremety1989> @FromIRC okey,thanks
* robacarp headdesk
watzon_ has quit [Ping timeout: 240 seconds]
watzon_ has joined #crystal-lang
daemonwrangler is now known as derek-away
watzon_ has quit [Client Quit]
watzon_ has joined #crystal-lang
derek-away is now known as daemonwrangler
snsei has joined #crystal-lang
juni0r has joined #crystal-lang
daemonwrangler is now known as derek-away
derek-away is now known as daemonwrangler
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
daemonwrangler is now known as derek-away
derek-away is now known as daemonwrangler
Alibaba has joined #crystal-lang
<Alibaba> Hi everyone
<FromGitter> <abidon> Hello, @Alibaba and I are participating to an Hackathon for the next 46 hours where performance and efficiency is the key to win. We decided to use crystal as our backend server tech. There are chances we need your knowledge on some of the parts of the language that we may not master yet. We hope to make it good and promote the language πŸ˜‰
<FromGitter> <bararchy> @abidon Good luck guys
<FromGitter> <sdogruyol> hey @abidon that's great to hear
<FromGitter> <sdogruyol> is it a public hackathon?
<FromGitter> <akzhan> looks like compiler progress stands on one point
<FromGitter> <abidon> Yes its called Design4Green
<FromGitter> <akzhan> No multithreading so far
<FromGitter> <abidon> http://design4green.org/en/
<Alibaba> Our goal is to create a search engine while consumming the least amount of ressources
<FromGitter> <fridgerator> sounds cool, good luck guys
<Papierkorb> hf&gl
daemonwrangler is now known as derek-away
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Read error: Connection timed out]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<Papierkorb> Alibaba: I'm interested in search engines, their algorithms/structures. Will your sources be available later on?
faustinoaq has quit [Ping timeout: 264 seconds]
faustinoaq has joined #crystal-lang
<FromGitter> <bew> @abidon cool, have fun ;)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <abidon> @Papierkorb I don't think our project will go deep in search engine algorithms. The main goal of the challenge is to raise awareness about "green coding". We only have to search inside a 1000 rows database. Our focus is definitely about producing optimized code, reducing bandwidth usage, reduce power consumption, ...
<FromGitter> <abidon> By the way if we don't have restrictions on going public, we'll do it
<Papierkorb> Don't play your efforts down. I'd be interest to hear about what you did differently to reduce power consumption
<Papierkorb> That alone is a perfectly worthwhile insight :)
<FromGitter> <bew> just to be sure (can't test now), a channel is bidirectional right?
txdv has quit [Ping timeout: 248 seconds]
<oprypin> bew, it does not have any directions
<oprypin> put things into it from anywhere, receive things from it anywhere
<FromGitter> <bew> yeah right, a channel is not like a pipe, at all, thanks!
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 250 seconds]
<FromGitter> <abidon> Just a small syntax question, how can i make ```{code: 10001}``` an Hash instead of a named tuple ?
<FromGitter> <abidon> Found it, just forget about it
snsei has joined #crystal-lang
<Papierkorb> In general, avoid using Symbol. They're not as ubiquous as in Ruby
<Papierkorb> If you do need a Hash (Consider using a proper class if it's data of known structure instead), use String as key if you thought about using Symbol
<FromGitter> <abidon> Thanks for the tip ! πŸ‘
txdv has joined #crystal-lang