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
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> `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>
<simaoneves> I think that the problem is that the hash literal is String => Float64 | Int32, and not *specifically* String => Float64 | Int32 | String
<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…]
<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]
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> 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> 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.