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
hightower4 has joined #crystal-lang
hightower3 has quit [Ping timeout: 255 seconds]
Creatornator has joined #crystal-lang
sz0 has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
Creatornator has joined #crystal-lang
snsei has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bararchy> Morning all :)
_whitelogger has joined #crystal-lang
<FromGitter> <Brusalk> mornin
<FromGitter> <Brusalk> Are macro hooks like `method_missing` instance-only, or is there a syntax to define them so that missing class methods are handled by `method_missing`?
<FromGitter> <imonmyown> Hey, morning guys :)
wontruefree has joined #crystal-lang
<FromGitter> <bararchy> Hi @imonmyown
<wontruefree> is there a way to call instance methods in a initialize
<FromGitter> <imonmyown> hat tip @bararchy :)
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> wontruefree yeah , just call them
<FromGitter> <bararchy> def too
<wontruefree> I am not seeing it work how I expect
<FromGitter> <bararchy> ``````
<wontruefree> same with structs right?
<FromGitter> <bararchy> just call them inside initialize , so let's say def foo; ... ; end , def initialize ; too ; end
<wontruefree> makes sense
<wontruefree> that is what I would expect
<FromGitter> <bararchy> What do you see that doesn't make sense
<FromGitter> <bararchy> ?
<wontruefree> well if I do x = Foo.new; x.bar it works
<wontruefree> if I have def initialize bar; end; and then Foo.new bar is not called
rohitpaulk has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
stnly_ has quit [Quit: leaving]
<FromGitter> <petoem> good morning
Papierkorb_ has joined #crystal-lang
<Papierkorb_> Morning
rohitpaulk has quit [Ping timeout: 255 seconds]
stnly has joined #crystal-lang
rohitpaulk has joined #crystal-lang
flaviodesousa has joined #crystal-lang
mark_66 has joined #crystal-lang
baweaver is now known as baweaver_away
<Groogy> Morning
DTZUZO has quit [Ping timeout: 246 seconds]
<Papierkorb_> Groogy: Could you build me a really small OpenGL application in C or Crystal? Then I could look into how bindgen behaves with it on the week end
<Groogy> that should give you enough samples :D
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] ysbaddaden closed pull request #5107: Measure time with monotonic clock (master...std-measure-time-with-monotonic-clock) https://git.io/vdKfb
claudiuinberlin has joined #crystal-lang
<FromGitter> <bararchy> wontruefree -> seems to work for me https://play.crystal-lang.org/#/r/2w7j
andersh has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <petoem> I am trying to pass a hash literal to a method that has a type restriction. The literal is of type `Hash(String, Int32|Float64)` and the restriction is `Hash(String,Int32|String|Float64)`
<FromGitter> <petoem> this works
<FromGitter> <petoem> but when I try to create a new instance of another class that assigns the hash as an instance variable (with the same restriction)
<FromGitter> <petoem> it doesn't work
<FromGitter> <petoem> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59df2c73bbbf9f1a384fd90f]
<FromGitter> <petoem> https://carc.in/#/r/2w7k
<FromGitter> <petoem> `foo` seems to accept the hash literal, because if i comment out `B.new data` line, it works
<crystal-gh> [crystal] ysbaddaden opened pull request #5108: Add Time.monotonic to return monotonic clock (master...std-time-monotonic) https://git.io/vdKSC
<FromGitter> <petoem> is the `@data : C` somehow stronger? ⏎ if foo accepts the hash why does initialize not?
rohitpaulk has quit [Ping timeout: 248 seconds]
rohitpaulk has joined #crystal-lang
<Papierkorb_> petoem, I'm not sure if this is a bug or not. However, you can explicitly type your hash literal using the of syntax: `{ "foo" => "bar" } of String => String | Int32`
<Papierkorb_> petoem, maybe you can also write `{} of SomeAlias`, but I've never tried
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<FromGitter> <petoem> @Papierkorb_ `{ "foo" => "bar" } of SomeAlias` does not work, but `SomeAlias{ "foo" => "bar" }` works. ⏎ the problem is `SomeAlias` is in my case`Mixpanel::Event::Properties` which is long. ⏎ it would be nice and more straightforward if the user could do `tracker.track "Page view", {"a" => 3, "b" => 3.4}` ⏎ regarding initialize ⏎ `def initialize(data : C)` does accept the hash, but doing something like
<FromGitter> ... `@mydata = data` does not work. ... [https://gitter.im/crystal-lang/crystal?at=59df3a1a01110b7231a7a9d0]
<FromGitter> <simaoneves> I think that the problem is that the hash literal is String => Float64 | Int32, and not *specifically* String => Float64 | Int32 | String
<FromGitter> <simaoneves> The String is missing
<FromGitter> <simaoneves> this works: https://carc.in/#/r/2w88
<FromGitter> <simaoneves> Not pretty, but it works because it instantiates the correct type restriction: https://carc.in/#/r/2w8g
<FromGitter> <petoem> i know, i left String out on purpose ⏎ to show that it passes through the type restriction of the method but cannot be assigned to a instance var of the same type
<FromGitter> <petoem> @simaoneves yes, its not pretty. i have been using `A::B::C.new`or `A::B::C{"a" => 3, "b" => 3.4}` for a while
<Papierkorb_> petoem, deep literal type deduction will be a while until we have it. It's a pretty complex and expensive operation.
<FromGitter> <simaoneves> @petoem oh right :)
ShalokShalom has joined #crystal-lang
<FromGitter> <petoem> @Papierkorb_ ok, i will have to stick to the available methods
<FromGitter> <petoem> @Papierkorb_ @simaoneves thanks for your help
<FromGitter> <simaoneves> @petoem Not much help, but i tried :P
DTZUZO has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bararchy> I wish we hade an option to do def :no-type-check foo; end
<FromGitter> <bararchy> Exactly for this
<FromGitter> <bararchy> Or even at a class level
<FromGitter> <bararchy> For when the type check can't really do his thing and just encumber the code
claudiuinberlin has joined #crystal-lang
<oprypin> bararchy, what are you talking about
<Groogy> bararchy the type check always needs to be done, otherwise it doesn't know how to generate the code
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sz0 has joined #crystal-lang
ShalokShalom has quit [Ping timeout: 260 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] ysbaddaden closed pull request #5106: Fix: CI is mising gmp dependency on macOS (master...fix-ci-missing-gmp-dependency-on-osx) https://git.io/vdoSF
<oprypin> straight-shoota, thanks, reopening it works. but i was sure i tried that once before!
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <straight-shoota> yeah, it looks like a weird glitch and they don't seem to get it fixed...
claudiuinberlin has joined #crystal-lang
<oprypin> i tried to report it but that takes a ridiculous amount of effort to sign up and post on their stupid forum where it would likely get ignored
<FromGitter> <straight-shoota> ¯\_(ツ)_/¯
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ShalokShalom has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
<FromGitter> <bararchy> oprypin I mean of a way to tell the compiler "trust me, this is going to be this type"
<oprypin> yes but you don't seem to undeerstand that it's not actually this type in that case that you were discussing
<oprypin> most importantly, a different memory layout
<oprypin> so you'd get horrible breakages is all
<FromGitter> <bararchy> Yeha, later I saw he specificlly had a different type, was talking more generally
<FromGitter> <bararchy> like with .not_nil!
<FromGitter> <bararchy> so `x : Int32!`
<FromGitter> <bararchy> or something
claudiuinberlin has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 255 seconds]
claudiuinberlin has joined #crystal-lang
Poeticode has left #crystal-lang [#crystal-lang]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
<Papierkorb_> Oh neat, Linux 4.14 supports virtual memory of up to 128PiB.
<Papierkorb_> (And no processor supports that much right now)
<FromGitter> <txdv> maybe you should create one
<Papierkorb_> if I was working at intel I'd be like "hold my beer" :P
<FromGitter> <fridgerator> lol
<FromGitter> <txdv> more like "hold my wafer"
rohitpaulk has joined #crystal-lang
Creatornator has joined #crystal-lang
<FromGitter> <straight-shoota> Hey isn't it nice that when processors have evolved to support such gigantic amounts, you can run an old linux on it? :P
<Papierkorb_> I'm actually more interested about the MMU supporting even the previous hard-limit of 64TiB of physical Memory (Which are reached by some systems?)
<Papierkorb_> Err, the memory controller
Papierkorb_ has quit [Quit: Konversation terminated!]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <iSarCasm> Hi, guys!
<Groogy> o/
<FromGitter> <iSarCasm> How could I refactor this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=59df86e501110b7231a97303]
rohitpaulk has joined #crystal-lang
<FromGitter> <zyriuse75> i make an error and i'm sure it's a stupid error but i cant find it :(
<FromGitter> <bew> you cannot instantiate a module
<FromGitter> <zyriuse75> 😄 thk and sorry
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <krypton97> Hey Groogy, are you on?
<Groogy> yepp
<Groogy> for another half hour
<FromGitter> <krypton97> Hi, where did you learn the gl shading language? I couldn't find a complete tutorial for c
<FromGitter> <krypton97> ..
<Groogy> oh I can't remember really.... I learnt it years ago
<Groogy> I mean I use the khronos wiki a lot as a resource
<Groogy> but hmm
<Groogy> didn't learn it from there but been good place ot look at when I got stuck on stuff
<Groogy> though it is super old shaders, actually nvm
<Groogy> hmm maybe it is enough to learn from that first tutorial on that list
<Groogy> ah yeah it teaches you tesselation as well I think so yeah that one should be "up to date enough"
<crystal-gh> [crystal] MakeNowJust opened pull request #5109: Codegen: compile untyped typeof(exp) correctly (master...fix/crystal/5105-compile-untyped-type-of-correctly) https://git.io/vd6Xd
<FromGitter> <krypton97> Thanks
<FromGitter> <krypton97> If it's not enough, I'll play with the shades untill I get it I guess
Creatornator has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Ping timeout: 255 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
flaviodesousa has quit [Quit: KVIrc 4.2.0 Equilibrium http://www.kvirc.net/]
Creatornator has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
claudiuinberlin has quit [Client Quit]
rohitpaulk has joined #crystal-lang
<FromGitter> <faustinoaq> Hi crystal community! Does someone know how many JavaScript web frameworks exist ?
<oprypin> we havent invented a number that high yet
mark_66 has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <faustinoaq> 😅
Creatornator has joined #crystal-lang
<Yxhuvud> @asterite: https://github.com/rust-lang/rust/pull/43506 was an interesting technique to reduce peak memory usage.
wontruefree has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
Groogy2 has quit [Quit: WeeChat 1.9]
<FromGitter> <eliasjpr> Is method_missing macro available within a module?
baweaver_away is now known as baweaver
<FromGitter> <eliasjpr> method_missing is invoked at compile-time when a method is not found. -> This seems to be scoped to a class only
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
<oprypin> eliasjpr, the macro is invoked when a method call on an instance fails. modules cannot be instantiated
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <eliasjpr> I figured, it would be nice to have it available in module IMHO I dont see why it has to be scope only to objects instances
<FromGitter> <eliasjpr> please illustrate me if there is a reason I would like to understand
<oprypin> i just told you
<FromGitter> <eliasjpr> ok
ragmaanir has joined #crystal-lang
<FromGitter> <eliasjpr> So if the object fails tor respond to a specific method call the compiler captures that somewhere, and if the object has the macro define it will call the method_missing hook. I dont understand why it has to be an instance, since the state of the object is not tied to the definition of the class
<FromGitter> <eliasjpr> does it make sense?
<ragmaanir> hi, is there a way to determine the root path of your project, e.g. a constant?
<FromGitter> <eliasjpr> *DIR*
<ragmaanir> undefined constant DIR (did you mean 'Dir')
<FromGitter> <eliasjpr> there is a \__DIR__
<ragmaanir> oh, i see, thanks
<FromGitter> <eliasjpr> and *FILE*
<ragmaanir> no, wait. thats not the root path of the project
DTZUZU has quit [Quit: WeeChat 1.9]
<ragmaanir> its the path of the file
<oprypin> ragmaanir, you would have to record the path in the file that you define as the root, because crystal does not define a root
<ragmaanir> ok, thanks
<oprypin> `ROOT_PATH = __DIR__`
DTZUZU has joined #crystal-lang
<ragmaanir> that is a little bit difficult for shards though. to get the path of the app one would have to pass it to the shard as parameter or define a constant with a naming convention.
<ragmaanir> or scan the parent path
<oprypin> ragmaanir, i think it's about time to ask what you're trying to do and what you mean by root path of project
<ragmaanir> well, there are two kinds of paths: root path of the app and root path of each shard.
<ragmaanir> i want to clean stacktraces of absolute paths
<oprypin> so moify the compiler? because otherwise i dont see how you'd do that
<ragmaanir> currently i used pwd and then pwd + /lib to get these paths.
<ragmaanir> though pwd is not great, dir is better
<ragmaanir> and for crystal i used "which crystal"
<oprypin> ragmaanir, these assumptions shatter extremely easily
<oprypin> pwd can be literally anything, crystal can be literally anywhere and not in PATH
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ragmaanir> yes, thats why i was asking for the constans. it was good enough for my personal use-cases though.
<FromGitter> <martinos> I just installed crystal on my mac using homebrew, and the compilation of a file is failing with the following error: libcrystal.a(sigfault.o)) was built for newer OSX version (10.12) than being linked (10.4)
<FromGitter> <martinos> Anyone has faced this issue?
<oprypin> ragmaanir, my recommendation is still to use __DIR__ in the file you define as main. pass it to the shard that wants to know it.
<FromGitter> <crisward> Are you on 10.4 ?
<ragmaanir> yes, thats what i will do now
<FromGitter> <martinos> No, I am on 10.12.6
<oprypin> ragmaanir, it's true that the main file can easily be defined as "the one you run `crystal build` with", but i dont know how to get that info
<ragmaanir> i think i used a macro
<FromGitter> <crisward> Weird error then. Have you launched xcode? it may do some update magic, not sure.
<ragmaanir> not sure if that actually works when shelling out in the macro
<FromGitter> <crisward> I'm on same version as you and brew install crystal-lang works fine.
<oprypin> martinos, can you confirm that this system was on 10.4 at some point in the past?
<FromGitter> <crisward> That'd be very old.
rohitpaulk has joined #crystal-lang
<FromGitter> <crisward> 2005?
<ragmaanir> `APP_COMPILE_ROOT = compile_time_command("readlink -f `pwd`")`, no idea how robust this would be. are the stacktraces generated from compile time paths?
<oprypin> :O
<oprypin> ragmaanir pls
<FromGitter> <martinos> 1) 4 is tiger, I have a MacBook Pro 2013.
<FromGitter> <martinos> So I was never on Tiger
<oprypin> this is the weirdest error
<ragmaanir> oprypin ?
<oprypin> ragmaanir, all i can say is that pwd is meaningless no matter how you frame it
<ragmaanir> that was my old solution which i am replacing with DIR. but are the stacktraces built based on compile time paths?
<oprypin> I don't know and I think you're in as good of a position to check
Creatornator has joined #crystal-lang
<FromGitter> <martinos> I have also this line in my compiler output: couldn't understand kern.osversion `16.7.0'
claudiuinberlin has joined #crystal-lang
ragmaanir has quit [Quit: Leaving]
Poeticode has joined #crystal-lang
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #crystal-lang
alex`` has quit [Ping timeout: 264 seconds]
<FromGitter> <martinos> @crisward , are you on crystal 0.23.1_3 ?
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
Creatornator has joined #crystal-lang
<FromGitter> <crisward> @martinos - `crystal -v` outputs - `Crystal 0.23.1 (2017-09-08) LLVM 4.0.1`
thefynx has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
olbat has quit [Ping timeout: 240 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <martinos> @crisward, I think this issue might be caused by a new version that was released on homebrew this morning. I have the same issue on my other mac which is running Sierra too.
<oprypin> martinos, can you point us to the new homebrew release and what changed in it?
<FromGitter> <martinos> @oprypin I don't think that it is a new version of crystal that broke the install on os x, but the homebrew formula. I am currently trying to install it manually on my computer.
<FromGitter> <martinos> Here is the formula in question: https://github.com/Homebrew/homebrew-core/blob/master/Formula/crystal-lang.rb
<FromGitter> <martinos> I am reverting back to 5fda3fd823953248ac3c3d8a6d9be90d71ec46f3 and I'll give you an update on the result.
<oprypin> i dont see any change in homebrew that is likely to cause this
<FromGitter> <martinos> I know at least that a previous version broke something: https://github.com/Homebrew/homebrew-core/commit/cbdd56f2688881f4782dc58a9fe3e445519f768f#comments
<FromGitter> <martinos> Maybe I am wrong
<FromGitter> <martinos> The new build doesn't work.
<FromGitter> <martinos> I am throwing in the towel. Thanks for your help
<FromGitter> <martinos> MMM, I just installed crystal on a Ubuntu box on Digital Ocean and when I try to build the server example in the doc I still get an error.
<FromGitter> <martinos> Error: execution of command failed with code: 1: `cc "${@}" -o '/root/.cache/crystal/crystal-run-coucou.tmp' -rdynamic -lz `command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'` -lpcre -lm -lgc -lpthread /opt/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib
<FromGitter> ... -L/usr/local/lib`
<FromGitter> <martinos> crystal run my_server.cr
<FromGitter> <martinos> Here is my file:
<FromGitter> <martinos> require "http/server" ⏎ ⏎ server = HTTP::Server.new(8080) do |context| ⏎ context.response.content_type = "text/plain" ⏎ context.response.print "Hello world! The time is #{Time.now}" ... [https://gitter.im/crystal-lang/crystal?at=59dff8cbbac826f054699178]
<FromGitter> <martinos> Maybe I am missing something but I think that there is something wrong.
<FromGitter> <martinos> /usr/bin/ld: cannot find -lz ⏎ /usr/bin/ld: cannot find -lssl ⏎ /usr/bin/ld: cannot find -lcrypto ⏎ /usr/bin/ld: cannot find -lcrypto [https://gitter.im/crystal-lang/crystal?at=59dff9b6614889d475a9fb1d]
<FromGitter> <bew> You need to install the missing libs
<FromGitter> <martinos> Do know which package we need to install ?
<FromGitter> <martinos> apt-get install libssl-dev