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
<oprypin> facepalm
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter> <Qwerp-Derp> Kindof...
<FromGitter> <Qwerp-Derp> Well, I just placed all the code in a Github gist
<FromGitter> <Qwerp-Derp> Cause I might need to use the code for later anyway
<FromGitter> <Qwerp-Derp> Anyway, the problem is somewhere in `lucas_u`, with subtracting a `BigInt` from an `Int32`, but I'm not sure how it caused a invalid memory access
<FromGitter> <Qwerp-Derp> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59851300bc4647297454e98e]
<FromGitter> <Qwerp-Derp> Hello?
<FromGitter> <Qwerp-Derp> Also, are there any BigDecimal classes in Crystal?
go|dfish has quit [Ping timeout: 260 seconds]
hightower has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
renich has quit [Ping timeout: 240 seconds]
<bmcginty> Qwerp-Derp: Look at BigFloat?
<FromGitter> <Qwerp-Derp> How would that help? My issue with this code is with subtraction of integers.
<bmcginty> Qwerp-Derp: You asked if Crystal had Big Decimal support, if I read correctly. Let me glance at your gist. might have to be afk for a bit but will reply when I return.
<FromGitter> <Qwerp-Derp> Oh yeah, that was before I discovered BigFloat :P sorry for the confusion, I deleted the message.
w-p has joined #crystal-lang
<bmcginty> Qwerp-Derp: Looking.
w-p has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 255 seconds]
<bmcginty> Qwerp-Derp: Let me see if I can change this code around a bit. I'm not sure if you're just overflowing? the stack, or even if that's possible, but your lucus call is recursing at least 20k+ levels deep...
<bmcginty> Qwerp-Derp: Sorry, your lucas_u call.
<bmcginty> Qwerp-Derp: Gotta say my brain is melting trying to figure this out.
go|dfish has joined #crystal-lang
<FromGitter> <johnjansen> anyone care to remind me how to solve this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59854efdc101bc4e3aed8fca]
<FromGitter> <johnjansen> like without validating the cert
chamar has joined #crystal-lang
chimkan has joined #crystal-lang
chimkan has quit [Quit: chimkan]
chimkan has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
chimkan has quit [Quit: chimkan]
<bmcginty> johnjansen: just a sec and I'll find this if you haven't. It's basically providing a new ssl context to the http (or wherever) function you need.
<bmcginty> johnjonson: I think `https://github.com/crystal-lang/crystal/blob/1f3e8b0e742b55c1feb5584dc932e87034365f48/spec/manual/badssl_spec.cr#L3` should show you. I remember writing someone a issue reply on this,b ut not sure where it's gone.
<FromGitter> <johnjansen> thats it alright, thanks … brain has disengaged for the weekend
alex`` has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
hightower has joined #crystal-lang
_whitelogger has joined #crystal-lang
alex`` has quit [Quit: WeeChat 1.9]
zaiste has joined #crystal-lang
_whitelogger has joined #crystal-lang
tzekid has joined #crystal-lang
pabs has quit [Ping timeout: 240 seconds]
pabs has joined #crystal-lang
bmcginty has quit [Ping timeout: 240 seconds]
Philpax has joined #crystal-lang
<FromGitter> <Qwerp-Derp> I think I fixed my algorithm slightly - it doesn't segfault, but it still doesn't do what i WANT IT TO DO
bmcginty has joined #crystal-lang
hightower is now known as hightower2
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zaiste has joined #crystal-lang
rohitpaulk has joined #crystal-lang
hightower2 has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
rohitpaulk has joined #crystal-lang
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zaiste has joined #crystal-lang
zaiste has quit [Client Quit]
alex`` has joined #crystal-lang
nikkkk has joined #crystal-lang
nikkkk has quit [Client Quit]
<FromGitter> <LuckyChicken91_twitter> *if "hello"[-1]=="o"* would be true, right?
<FromGitter> <bew> It's a Char not a String
<FromGitter> <bew> So 'o', not "o"
<FromGitter> <LuckyChicken91_twitter> ooooh.. facepalm
<FromGitter> <abidon> Hi guys I think there's a bug in crystal compiler: https://play.crystal-lang.org/#/r/2h4h
<FromGitter> <abidon> Did someone experienced this or at least have one explication
zaiste has joined #crystal-lang
<FromGitter> <straight-shoota> if you call `priv` on `self`, a public method is expected
<FromGitter> <straight-shoota> https://play.crystal-lang.org/#/r/2h4j
<FromGitter> <abidon> Yeah but why this ?
<FromGitter> <abidon> In C++ you can call private methods by expliciting `this` or not, it works both way
<FromGitter> <straight-shoota> https://crystal-lang.org/docs/syntax_and_semantics/visibility.html ⏎ ⏎ > A private method can only be invoked without a receiver, that is, without something before the dot:
<FromGitter> <abidon> Ok so i'm blind 😄
<FromGitter> <abidon> But I still find this really strange
<FromGitter> <straight-shoota> Well, it's perfectly fine that you expect this to be different. But because they are only visible in the current type (and subtype), it makes sense to call them without a receiver.
<FromGitter> <faustinoaq> I didn't realize I can write all crystal code in one line:
<FromGitter> <faustinoaq> ```code paste, see link```
<FromGitter> <faustinoaq> 😅
<FromGitter> <faustinoaq> And works as expected: ⏎ ⏎ ```$ crystal huffman.cr ⏎ h => 000 ⏎ l => 001 ⏎ o => 01 ⏎ a => 1``` [https://gitter.im/crystal-lang/crystal?at=5985bd3876a757f80878c5bc]
hightower2 has joined #crystal-lang
<FromGitter> <faustinoaq> In Python and Nim I can't do that because indentation, Maybe another advantage of `end` keyword
<oprypin> so how exactly is this an advantage?
<FromGitter> <konovod> @faustinoaq the next problem is significant spaces! they prevent better codegolfing.
<oprypin> code golfing has undergone terrible "inflation" in that you have no hope to win unless you have a very specialized language that has a different command for each byte
<FromGitter> <faustinoaq> <oprypin> Maybe code obfuscation or code art like this: https://github.com/knoxknox/qlobe
<oprypin> so how exactly is this an advantage?
<FromGitter> <LuckyChicken91_twitter> what?
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <faustinoaq> *<oprypin>* 😅 Not advantage at all but funny
<FromGitter> <LuckyChicken91_twitter> its definitely an advantage
<FromGitter> <faustinoaq> @konovod Oh, I see `codegolfing` is the term 👍
<FromGitter> <faustinoaq> then Crystal is good for codegolfing 😆
<jokke> hey
<jokke> is there any implementation of the repository pattern for crystal?
<oprypin> pls give a reference of what that is
<FromGitter> <LuckyChicken91_twitter> can someone explain me "fun"?
<jokke> oprypin: well it's a database access pattern
<jokke> your models are plain data mappings and the repositories are plain ol' classes that provide a database-agnostic abstraction layer for accessing the db (and turning the db records into objects)
<FromGitter> <veelenga> @jokke are you looking for this https://github.com/Crecto/crecto ?
<FromGitter> <faustinoaq> @LuckyChicken91_twitter `fun` is just like C functions, no overloading and restricted types. Is commonly on C bindings.
<FromGitter> <LuckyChicken91_twitter> ooh i can define functions with fun
<jokke> vegai: kind of...
<jokke> it's weird, because it seems to have only one repo
<jokke> usually you have one per model class
<FromGitter> <faustinoaq> @LuckyChicken91_twitter yes, but `fun`'s are restricted to some types, see: https://crystal-lang.org/docs/syntax_and_semantics/c_bindings/fun.html
<jokke> so you can extend it with model-specific queries for example
<jokke> vegai: but that's a good start
<FromGitter> <faustinoaq> @veelenga you should include Repo patter on your pattern guide 😅 https://github.com/veelenga/crystal-patterns
w-p has joined #crystal-lang
<FromGitter> <veelenga> @faustinoaq it is missing a lot for now. I have at least to finish with Gof patterns some day 😄
<FromGitter> <faustinoaq> 😄 👍
<FromGitter> <LuckyChicken91_twitter> lib C ⏎ fun cos(value : Float64) : Float64 ⏎ end ⏎ ⏎ C.cos(1.5) ... [https://gitter.im/crystal-lang/crystal?at=5985c9f2210ac269205785d3]
<FromGitter> <faustinoaq> https://carc.in/#/r/2h52
<FromGitter> <faustinoaq> LibC is already in stdlib
<FromGitter> <LuckyChicken91_twitter> do i need to use lib C to define functions
<FromGitter> <faustinoaq> No, you don't ⏎ ⏎ ```fun sum(a : Int32, b : Int32) : Int32 ⏎ a + b ⏎ end ⏎ ⏎ pp sum(1,2)``` [https://gitter.im/crystal-lang/crystal?at=5985cd39bc4647297456eb41]
<FromGitter> <faustinoaq> https://carc.in/#/r/2h5j
<FromGitter> <faustinoaq> Just need to define types
<FromGitter> <faustinoaq> parameter types are mandatory on `fun`
<FromGitter> <LuckyChicken91_twitter> im not so good at functions
bcardiff has joined #crystal-lang
<FromGitter> <faustinoaq> just use `def` 😅
<FromGitter> <faustinoaq> `def` has type inference
_whitelogger has joined #crystal-lang
<FromGitter> <LuckyChicken91_twitter> but im finding it really cool that crystal is supporting functions
snsei has joined #crystal-lang
<oprypin> what a unique feature
<FromGitter> <LuckyChicken91_twitter> oh yes
<FromGitter> <LuckyChicken91_twitter> but i think i dont will need functions because def and fun is somehow really similar
<FromGitter> <faustinoaq> `fun` is more low level than `def`
<FromGitter> <LuckyChicken91_twitter> can someone explain me `lib`
<oprypin> :(
<FromGitter> <fridgerator> @jokke There are others, but 2 frameworks I've used that use the Repo pattern an Hanami (Ruby) and Ecto (Elixir). Hanami uses a repo per model, and Ecto you define as many Repos as you want usually one per database.
Philpax has quit [Ping timeout: 276 seconds]
Philpax has joined #crystal-lang
<FromGitter> <fridgerator> Crecto being obviously more like Ecto
<FromGitter> <faustinoaq> @LuckyChicken91_twitter We know Crystal still lacks some documentation 😜 but at least the common language features are documented, check https://crystal-lang.org/docs/, https://crystal-lang.org/api/0.23.1/ and http://devdocs.io/crystal/
alibby has joined #crystal-lang
<FromGitter> <LuckyChicken91_twitter> is it by the way somehow possible to help translating the crystal lang website?
<FromGitter> <fridgerator> the api docs?
<FromGitter> <LuckyChicken91_twitter> no maybe just crystal-lang.org
<FromGitter> <fridgerator> there are a few already
<FromGitter> <LuckyChicken91_twitter> also german?
bcardiff has quit [Quit: bcardiff]
<FromGitter> <LuckyChicken91_twitter> i could help making the german translation of crystal-lang.org
<FromGitter> <fridgerator> make a PR similar to this one: https://github.com/crystal-lang/crystal/issues/1719
<FromGitter> <faustinoaq> @LuckyChicken91_twitter Google traductor works for me 😜, Maybe @jhass can help you, He is German too.
<FromGitter> <LuckyChicken91_twitter> google translate is not always safe
<FromGitter> <faustinoaq> Yeah, But I use Crystal unsafe (https://crystal-lang.org/docs/syntax_and_semantics/unsafe.html) too 😝 (is a joke)
<FromGitter> <fridgerator> lol
<FromGitter> <fridgerator> always practice safe crystal
<FromGitter> <faustinoaq> Yeah, is more healthy 😆
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <straight-shoota> @LuckyChicken91_twitter well, translating is one thing - but if you publish a language it also needs to be maintained to track changes in upstream. It's better not to have a localized website or docs than to have outdated one which just confuses people. ⏎ And honestly I don't see any point in creating translations until at least the language is stable and the main docs are somewhat finished. There are
<FromGitter> ... still big gaps and many things will probably change before 1.0. ⏎ So I'd recommend to work on improving the English documentation instead. Let's take small steps and finish one thing after the other.
<FromGitter> <LuckyChicken91_twitter> okay
snsei has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
leandrobighetti has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
chamar has quit [Quit: Leaving]
leandrobighetti has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
leandrobighetti has joined #crystal-lang
zaiste has joined #crystal-lang
bradleyd has joined #crystal-lang
<bradleyd> is there a way to dynamically create a channel? For example, instantiate a channel based on input. Thanks!
<crystal-gh> [crystal] pacuum opened pull request #4797: Fixed #4796: IO::Buffered returned short buffer prematurely (master...bufferedio-boundary) https://git.io/v7rvy
<oprypin> bradleyd, you'll have to elaborate on that. i dont see anything about it that's not dynamic
http_GK1wmSU has joined #crystal-lang
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] matiasgarciaisaia pushed 1 new commit to master: https://git.io/v7rfk
<crystal-gh> crystal/master b5dd948 Ary Borenszweig: Fix #4639: Macro lookup from included module broken
http_GK1wmSU has left #crystal-lang [#crystal-lang]
<bradleyd> sure, i want to be able to pass some any type into a constructor and build a channel from that.
<bradleyd> For example, @channel = Channel(channel_type).new Throws error
<FromGitter> <faustinoaq> <bradleyd>, you mean something like 👉 https://carc.in/#/r/2h6b
<FromGitter> <faustinoaq> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5985f03dbc46472974576387]
leandrobighetti has quit [Remote host closed the connection]
<FromGitter> <bradleyd> yes
<FromGitter> <bradleyd> thanks @faustinoaq
<travis-ci> crystal-lang/crystal#b5dd948 (master - Fix #4639: Macro lookup from included module broken): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/261336456
<travis-ci> crystal-lang/crystal#b5dd948 (master - Fix #4639: Macro lookup from included module broken): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/261336456
Philpax has quit [Ping timeout: 258 seconds]
bcardiff has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
bcardiff has quit [Client Quit]
leandrobighetti has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest18728
leandrobighetti has quit [Ping timeout: 276 seconds]
<crystal-gh> [crystal] pacuum closed pull request #4797: Fixed #4796: IO::Buffered returned short buffer prematurely (master...bufferedio-boundary) https://git.io/v7rvy
tzekid has quit [Remote host closed the connection]
mbuf has joined #crystal-lang
<FromGitter> <LuckyChicken91_twitter> uh for what can I do for example `exit(21)`, `exit("hello ")` etc
<FromGitter> <LuckyChicken91_twitter> ?
leandrobighetti has joined #crystal-lang
leandrobighetti has quit [Remote host closed the connection]
mbuf has left #crystal-lang ["Ex-Chat"]
zaiste has joined #crystal-lang
Guest18728 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
trapped has quit [Ping timeout: 246 seconds]
olbat is now known as olbat_
olbat_ is now known as olbat
Renich has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest52379
<FromGitter> <LuckyChicken91_twitter> is someone here
rohitpaulk has joined #crystal-lang
<FromGitter> <picatz> I'm here. But, not really sure about your question ( if it's the previous one ).
<FromGitter> <LuckyChicken91_twitter> yes
<FromGitter> <LuckyChicken91_twitter> why can I do `exit("helloo")`?
<FromGitter> <picatz> Can you run that?
<FromGitter> <picatz> I can't seem to get that to run. I know `exit` is usually given an integer, which will be the error code for why the application failed ( typically non-zero ).
<FromGitter> <picatz> I would usually use `exit` like `exit(0)` to show the command successful completed.
<FromGitter> <picatz> I would use `exit(1)` or something other than `0` to show that the command failed.
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <LuckyChicken91_twitter> but where can I view this what i returned??
<FromGitter> <LuckyChicken91_twitter> where can the user see the error code
<FromGitter> <picatz> That would be in the shell. There's a variable `$?` that has the status of the last returned command.
<FromGitter> <straight-shoota> the exit code is returned to the invoking environment
<FromGitter> <picatz> If you want to provide further context, try adding a `puts "This is why you failed"; exit(1)` to let the user know what happened.
<FromGitter> <straight-shoota> see https://crystal-lang.org/api/0.23.1/toplevel.html#exit%28status%3D0%29%3ANoReturn-class-method
<FromGitter> <straight-shoota> and https://en.wikipedia.org/wiki/Exit_status
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest52379 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest75975
<FromGitter> <LuckyChicken91_twitter> if im doing puts $? then im getting an error
<FromGitter> <LuckyChicken91_twitter> ooh if im doing "echo $?" then im getting the thing i returned in the exit
<FromGitter> <picatz> Yeah. The `$?` will be in the context of the shell.
<FromGitter> <LuckyChicken91_twitter> but for what is this? i think it would be a lot smarter then to write the number directly in the program or write a message why it failed, if it failed
<FromGitter> <picatz> This is shell behavior. Typically exit codes will correlate to some specific reason. So, `137` might be a specific status that might mean something. You can still provide further diagnostic information to the user in STDERR or something like that.
<FromGitter> <LuckyChicken91_twitter> i will never use a exit code i think
<FromGitter> <picatz> It's helpful to provide at least a non-zero exit code if your program fails for some reason.
<FromGitter> <picatz> At least if it's a command-line application.
<FromGitter> <picatz> Of course most of that, honestly, is just personal opinion. But, I think it's nice to do.
<FromGitter> <straight-shoota> you might not use an exit code explicitly but every Crystal program returns an exit code, by default it's `0`
zaiste has joined #crystal-lang
<FromGitter> <picatz> I'm pretty sure, without exception, all programs you run in your shell have an exit code, right?
<FromGitter> <picatz> *I hate speaking in absolutes, but I'm pretty sure.*
<FromGitter> <bew> Yes they have
Guest75975 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <dishcandanty> (new to crystal, been experimenting with it.) trying to use vs code with a linter extension. I was going to put an issue on the extension, but think it may be my project structure or crystal installation. Build is fine. I'm getting this error: ⏎ ⏎ ```while requiring "prelude": can't find file 'prelude' relative to 'src/file.cr'``` [https://gitter.im/crystal-lang/crystal?at=59863a0af5b3458e30b3aed5]
<FromGitter> <dishcandanty> it looks like its looking for this: https://github.com/crystal-lang/crystal/blob/master/src/prelude.cr. so maybe the context of the linter is bad
_tsound has joined #crystal-lang
<_tsound> hello :P\
<FromGitter> <fridgerator> @dishcandanty I don't use vscode, but @faustinoaq does. I would ask him about it
<FromGitter> <fridgerator> If he's around
d33pb00k-GK1wmSU has joined #crystal-lang
<_tsound> "return -1" throws an error, right?
<FromGitter> <dishcandanty> @fridgerator thx!
d33pb00k-GK1wmSU has left #crystal-lang [#crystal-lang]
<_tsound> is there a way to impliment spinlocks currently?
<_tsound> or can i call in from a C libary?
rohitpaulk has joined #crystal-lang
alex`` has quit [Ping timeout: 246 seconds]
_tsound has quit [Quit: WeeChat 1.9]
_tsound has joined #crystal-lang
<FromGitter> <PushergeneXXL_twitter> Guys, how can i compile on Windows?
<oprypin> PushergeneXXL_twitter, generally you can't, but see https://github.com/crystal-lang/crystal/pull/3582#issuecomment-314086427