jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.7.4 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
ashleyis has quit [Quit: WeeChat 1.2]
ashleyis has joined #crystal-lang
<ozra_> Is it possible to define macros in macros?
havenn has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
havenwood has quit [Ping timeout: 256 seconds]
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vt21r
<crystal-gh> crystal/master 1fe01c5 Ary Borenszweig: More complete Comparable documentation, and check reference equality in `==` for Reference types.
<crystal-gh> crystal/master 86059ab Ary Borenszweig: Fixed error message when trying to splat something that's neither a tuple nor a union
<travis-ci> manastech/crystal#86059ab (master - Fixed error message when trying to splat something that's neither a tuple nor a union): The build passed. https://travis-ci.org/manastech/crystal/builds/68742376
vikaton has quit [Quit: Connection closed for inactivity]
fowlduck has joined #crystal-lang
fowlduck has quit [Ping timeout: 248 seconds]
vikaton has joined #crystal-lang
havenn is now known as havenwood
NeverDie has joined #crystal-lang
waj has quit [Quit: waj]
fowlduck has joined #crystal-lang
waj has joined #crystal-lang
fowlduck has quit [Ping timeout: 252 seconds]
ozra_ has quit [Ping timeout: 246 seconds]
fowlduck has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
genericpenguin has joined #crystal-lang
<genericpenguin> hi. I'm having an issue with the C fun declaration. Specifically, passing pointers char arrays. I'm trying to declare readlink in Crystal
<genericpenguin> ssize_t readlink(const char *path, char *buf, size_t bufsiz), but I can't get crystal to recognise the pointer declarations. I create a Char array and create a pointer to it using pointerof
<genericpenguin> But when compiling, it complains that the function is expecting a Char pointer (Char*) instead of a Char array pointer (Array(Char)*).
<genericpenguin> I expect I'm doing something very stupid (IANAP) but I have gone through the docs, apis, numerous chat logs of #crystal-lang but have been unable to hit the nail on the head.
<willl> you want to pass a string from crystal to a C char* ?
<genericpenguin> yep
<willl> so a C char has to be a UInt8 from crystal, I alias that, just so it looks a bit nicer, but that isn't necessary
<willl> and then using it, you just pass a string https://github.com/will/crystal-pg/blob/master/src/pg/connection.cr#L5
<genericpenguin> Great, thanks heaps! I will give that a whack.
waj has quit [Quit: waj]
strcmp1 has joined #crystal-lang
<genericpenguin> so it compiles and runs fine, but the empty string I pass to readlink (which is the buffer that will have the results) is empty. Does it work differently if I'm passing a string that I want to be written back?
<willl> yes, for that you either want the out keyword, or to do it manually
<willl> try out first though
<willl> actually out should work, the case I was remembering where I had to do something manually was a c function that would move a pointer you passed in to a weird data structure, so you shouldn't need to worry about that
<genericpenguin> So how would that work for a string, when UInt8 is a single value? It compiles fine but I just get a zero in the output.
<willl> ok, yeah, if you have the pointer to that, String.new has an initialize method that takes pointers to strings, or if that third parameter there is the size, slice might be the right thing to look at since it has bounds checking
<crystal-gh> [crystal] yui-knk opened pull request #899: Implement Hash#merge with block (master...feature/hash_merge_block) http://git.io/vtaBL
lokulin has joined #crystal-lang
lokulin has quit [Changing host]
bcardiff has joined #crystal-lang
<willl> genericpenguin: I played around with it, and found out I think you'll need a slice
<genericpenguin> willl: I tried your gist but I get an empty string. I'm using crystal 0.7.3 on a Mac (10.10). Might that be a problem? I'm going to try it on one of my C7 boxes since that's where they'll be running anyway
<willl> are you sure you're passing in a full path to a symlink?
<willl> what is the return code of the function?
<genericpenguin> -1 is the return code but I figure it's a mac thing. I just ran it on Centos 7 and it works fine
<willl> my run there was 0.7.4 on os x
<genericpenguin> hmmm. I might be doing something non-kosher. I'm going to have another check for sheer stupidity
<genericpenguin> Yep, I fat-fingered the ln. Works as expected
<willl> :)
<willl> also it looks like this lib sets errno, so p Errno.new("error") would have printed
<willl> #<Errno:0x10ab3ffc0 @message="error: Invalid argument", @cause=nil, @backtrace=[ ......
<willl> you should probably raise that if the response is -1
<genericpenguin> ah cool. Thanks for all your help.
vegai_ has joined #crystal-lang
vegai_ has quit [Ping timeout: 256 seconds]
vegai_ has joined #crystal-lang
<willl> good luck
vegai_ has quit [Ping timeout: 250 seconds]
vegai_ has joined #crystal-lang
vegai_ has quit [Ping timeout: 252 seconds]
vegai_ has joined #crystal-lang
Ven has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
ytti has joined #crystal-lang
dtscode is now known as dtscodefish
dtscodefish is now known as dtscode
sandelius has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
vegai__ has joined #crystal-lang
vegai_ has quit [Ping timeout: 248 seconds]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
BlaXpirit has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
sandelius has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
vegai__ has quit [Ping timeout: 246 seconds]
vegai_ has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ashleyis has quit [Ping timeout: 246 seconds]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 256 seconds]
Ven has joined #crystal-lang
daneb has joined #crystal-lang
sandelius has joined #crystal-lang
daneb_ has joined #crystal-lang
daneb has quit [Read error: Connection reset by peer]
daneb_ is now known as daneb
vegai_ has quit [Ping timeout: 272 seconds]
vegai_ has joined #crystal-lang
havenwood has quit [Ping timeout: 276 seconds]
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sandelius has joined #crystal-lang
vegai_ has quit [Ping timeout: 252 seconds]
vegai_ has joined #crystal-lang
ozra has joined #crystal-lang
Kilobyte22 has joined #crystal-lang
<Kilobyte22> the compiler claims $?.success returns NoReturn
vegai_ has quit [Quit: Lost terminal]
<Kilobyte22> why
<Kilobyte22> actually apparently $? is
<jhass> >> $?
<DeBot> jhass: Exception: Nil assertion failed - more at http://carc.in/#/r/5w7
<jhass> >> `ls`; $?
<DeBot> jhass: # => #<Process::Status:0x9cf2f00 @pid=87, @exit=0, @output=""> - http://carc.in/#/r/5w8
<jhass> ?
<jhass> >> `ls`; $?.success
<DeBot> jhass: Error in line 4: undefined method 'success' for Process::Status (did you mean 'success?'?) - http://carc.in/#/r/5w9
<jhass> >> `ls`; $?.success?
<DeBot> jhass: # => true - http://carc.in/#/r/5wa
<jhass> idk where you even have success from, it's success?
<Kilobyte22> yeah got that as well
<Kilobyte22> root_worker.cr:22: type must be JSON::Type, not NoReturn
<Kilobyte22> $?.success?
<Kilobyte22> uh that was not intended to be multiline
<Kilobyte22> sorry
jtarchie has joined #crystal-lang
<Kilobyte22> anyways, that is in a block that shall return JSON::Type
<Kilobyte22> which contains Bool
<jhass> Kilobyte22: $? may raise as I've showed
<jhass> so it's not success that has the NoReturn, it's $? already
<Kilobyte22> ohhhh
<Kilobyte22> ffs, why did i not realize that earlier
<jhass> but that's probably a bug, NoReturn shouldn't count in the block return type as such
<Kilobyte22> yeah
<jhass> >> def foo(&block : -> JSON::Type); block.call; end; foo { raise }
<DeBot> jhass: Error in line 4: wrong number of arguments for 'raise' (0 for 1) - http://carc.in/#/r/5we
<jhass> >> def foo(&block : -> JSON::Type); block.call; end; foo { raise "foo" }
<DeBot> jhass: Error in line 4: undefined constant JSON::Type - http://carc.in/#/r/5wf
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; foo { raise "foo" }
<DeBot> jhass: Exception: foo - more at http://carc.in/#/r/5wg
<Kilobyte22> $?.success? as Bool as JSON::Type
<Kilobyte22> that should work
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; def bar; raise "foo" if {true, false}.sample; true; end; foo { bar }
<DeBot> jhass: in line 4: undefined method 'sample' for {Bool, Bool} - http://carc.in/#/r/5wh
<Kilobyte22> or not. can't cast NoReturn to Bool
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; def bar; raise "foo" if [true, false].sample; true; end; foo { bar }
<DeBot> jhass: Exception: foo - more at http://carc.in/#/r/5wi
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; def bar; raise "foo" if [true, false].sample; true; end; foo { bar }
<DeBot> jhass: Exception: foo - more at http://carc.in/#/r/5wj
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; def bar; raise "foo" if [true, false].sample; true; end; foo { bar }
<DeBot> jhass: Exception: foo - more at http://carc.in/#/r/5wk
<jhass> >> require "json"; def foo(&block : -> JSON::Type); block.call; end; def bar; raise "foo" if [true, false].sample; true; end; foo { bar }
<DeBot> jhass: Exception: foo - more at http://carc.in/#/r/5wl
<jhass> mmh
<jhass> bad luck :D
<jhass> anyway, I'd call type interference bug
<Kilobyte22> yeah
<jhass> try $?.success? rescue false as workaround
<Kilobyte22> what debian package is libpcl.so?
<Kilobyte22> because for some reason i get "/usr/bin/ld: cannot find -lpcl"
<Kilobyte22> apparently there is libpcl-dev but i can't seem to install it (probably because mint is outdated - as usual)
<Kilobyte22> bbl
Kilobyte22 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
NeverDie has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vtrG5
<crystal-gh> crystal/master 6d5b880 Ary Borenszweig: Merge pull request #899 from yui-knk/feature/hash_merge_block...
<crystal-gh> crystal/master 705f0c9 yui-knk: Implement Hash#merge with block
<crystal-gh> [crystal] asterite pushed 2 new commits to master: http://git.io/vtrnT
<crystal-gh> crystal/master a8e6c6a Ary Borenszweig: Small simplification in `Array#at`
<crystal-gh> crystal/master 32e032d Ary Borenszweig: Reuse `Hash#merge!` with block in `Hash#merge` with block. Related to #899
Kilobyte22 has joined #crystal-lang
<Kilobyte22> and i'm back
sandelius has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Kilobyte22> why does crystal even link my program against libpcl
asterite has joined #crystal-lang
<asterite> Kilo`byte: what's the issue with $? ?
<Kilobyte22> asterite: apparently since it can also throw, the NoReturn gets messed up inside a block with explicit return type set
<asterite> Kilobyte22: do you have a snippet?
<asterite> $? is weird because it's only "defined" if you invoke a call that sets it, otherwise it gets the "NoReturn" type because it always raises
bcardiff has joined #crystal-lang
<asterite> That's because only system and backtick (`) set $?
<asterite> Process.run already returns the status
<Kilobyte22> oh hmm...
<asterite> But of course thee's no way for you to know it because it's not documented
<Kilobyte22> well, what would i do with async Process.run
<asterite> But we can make Process.run also set it, sounds reasonable
<Kilobyte22> that as well
<Kilobyte22> yeah
<Kilobyte22> is $? thread local?
<asterite> No, it's method local
<asterite> it's implemented by defining $? in the method where the call is, and passing a pointer to it to the method that defines it
<asterite> So basically Process.run also receives a pointer to $? and sets it
<asterite> (well, Process.run does that now that I fixed it :-P)
<asterite> It's done that way so there's no problem with concurrency... that was our main issue with those magic vars
<Kilobyte22> yeah, thats even a better solution
<Kilobyte22> :D
<asterite> but honestly I'd still like to remove them, even if they'll make some code larger/harder to read
<Kilobyte22> because race conditions
<Kilobyte22> maybe, yeah
<jhass> asterite: so the compiler detects it always raises and thus doesn't ignore NoReturn because it's not a union?
sandelius has joined #crystal-lang
ashleyis has joined #crystal-lang
sandelius has quit [Client Quit]
<asterite> When you do "$~", that actually it parsed to "$~.not_nil!", where "$?" is just a regular variable that is automatically defined when used
<asterite> Well, $~/$?
<Kilobyte22> now to figuring out why crystal links against libpcl
<Kilobyte22> .not_nil! sounds useful
<asterite> because it was never set a value, it gets the type Nil (it always has that type anyway), and nil.not_nil! always raises and that is typed as NoReturn
<asterite> Kilobyte22: but don't worry, in a next release waj will push the new-fibers branch which does the context switch in assembly, and we won't need libpcl anymore :)
<Kilobyte22> i want that now D: because libpcl apparently is not in mint sources
<Kilobyte22> nvm unexpected package name
<Kilobyte22> sudo pacapt -S libpcl1-dev
<Kilobyte22> should be it
<asterite> You can manually merge the new-fibers branch locally and create a compiler out of it. I'm not sure it's well tested, though, and it only works in x64_64 (as usual -_-)
<Kilobyte22> w/e
<jhass> >> def foo(&block : -> Bool); block.call; end; foo { nil.not_nil! }
<DeBot> jhass: Exception: Nil assertion failed - more at http://carc.in/#/r/5wo
<travis-ci> manastech/crystal#6d5b880 (master - Merge pull request #899 from yui-knk/feature/hash_merge_block
<jhass> ^ that compiles, why doesn't http://carc.in/#/r/5wn ?
Ven has joined #crystal-lang
<Kilobyte22> ffs
<Kilobyte22> c/aurgrab.cr/main.o: In function `__crystal_main':
<Kilobyte22> main_module:(.text+0x55e9): undefined reference to `GC_get_push_other_roots'
<asterite> jhass: don't know, maybe a bug. If you add .success? after the not_nil! it crashes the compiler :-s
<travis-ci> manastech/crystal#32e032d (master - Reuse `Hash#merge!` with block in `Hash#merge` with block. Related to #899): The build passed. https://travis-ci.org/manastech/crystal/builds/68815393
<jhass> Kilobyte22: just patch your LD_LIBRARY_PATH to include /opt/crystal/embedded/lib or whatever it was
<Kilobyte22> jhass: thats compile time
<jhass> I think there was an env var for that too
<jhass> or --link-flags="-L..."
<Kilobyte22> i give up, time to create an arch chroot
<jhass> :P
waj_ has joined #crystal-lang
<Kilobyte22> err wrong file
<travis-ci> manastech/crystal#68802b0 (master - Make Process#run set $?): The build passed. https://travis-ci.org/manastech/crystal/builds/68817235
asterite has quit [Quit: Page closed]
Ven has quit [Ping timeout: 244 seconds]
<Kilobyte22> ffs don't tell me i need a VM
<jhass> you don't need a VM
<jhass> what's the issue?
<Kilobyte22> pacman cannot find /etc/mtab even though its there
<Kilobyte22> i assume something with chroot is broken
<jhass> systemd-nspawn <3
<Kilobyte22> whats that do? how do i use that?
<jhass> mmh, I don't think it works of your /bin/init isn't systemd
<Kilobyte22> yeah, mint uses sysvinit
<Kilobyte22> (or upstart, forgot which)
<Kilobyte22> mint ships with systemd-nspawn though
<Kilobyte22> or not
<Kilobyte22> oh wait
<jhass> if it's there either sudo systemd-nspawn -D chroot_dir or sudo systemd-nspawn -bD chroot_dir should just work
<Kilobyte22> nope
<Kilobyte22> no such luck
<Kilobyte22> too bad that arch has issues on this machine
<Kilobyte22> jhass: thanks for telling me about systemd-nspawn though
<Kilobyte22> systemd <3
<jhass> (note with systemd-nspawn you need to setup nothing, no tmpfs, no /dev/ stuff, no mtab, no resolv.conf, point it to a rootfs and it works
<Kilobyte22> yeah, thats what i expected :P
<jhass> also if your / is btrfs, systemd-nspawn -xbD / boots a temporary snapshot of it xD
<Kilobyte22> jhass: <333
<Kilobyte22> yes, my root is btrfs :P
BlaXpirit has quit [Quit: Quit Konversation]
ashleyis_ has joined #crystal-lang
<Kilobyte22> whatever i'll fix that later when i am on my pc
<Kilobyte22> may i note that mint sucks for development? :P
BlaXpirit has joined #crystal-lang
daneb has quit [Remote host closed the connection]
Kilobyte22 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
ashleyis has quit [Quit: WeeChat 1.2]
ashleyis_ has quit [Quit: ZNC - http://znc.in]
ashleyis has joined #crystal-lang
havenwood has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
Ven has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vto0g
<crystal-gh> crystal/master 5339827 Ary Borenszweig: Fixed #895: some issues with macros and quote escaping
shama has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 276 seconds]
NeverDie has joined #crystal-lang
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
daneb has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff1 has quit [Ping timeout: 264 seconds]
daneb_ has joined #crystal-lang
daneb has quit [Read error: Connection reset by peer]
NeverDie_ has joined #crystal-lang
NeverDie has quit [Ping timeout: 265 seconds]
waj has joined #crystal-lang
waj_ has quit [Ping timeout: 252 seconds]
daneb_ has quit [Remote host closed the connection]
NeverDie has joined #crystal-lang
daneb has joined #crystal-lang
NeverDie_ has quit [Ping timeout: 272 seconds]
NeverDie_ has joined #crystal-lang
NeverDie has quit [Ping timeout: 272 seconds]
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
fowlduck has joined #crystal-lang
waj_ has joined #crystal-lang
waj has quit [Ping timeout: 264 seconds]
waj_ is now known as waj
NeverDie_ is now known as NeverDie
waj_ has joined #crystal-lang
waj has quit [Ping timeout: 264 seconds]
waj_ is now known as waj
fowlduck has quit [Remote host closed the connection]
bcardiff1 has joined #crystal-lang
bcardiff has quit [Ping timeout: 272 seconds]
fowlduck has joined #crystal-lang
bcardiff1 has quit [Quit: Leaving.]
<crystal-gh> [crystal] asterite closed pull request #848: Add link to API docs (gh-pages...gh-pages) http://git.io/vte8p
NeverDie_ has joined #crystal-lang
NeverDie has quit [Ping timeout: 246 seconds]
<willl> wow way more faces on the crystal
bcardiff has joined #crystal-lang
<BlaXpirit> still really few compared to github stars
ozra has quit [Ping timeout: 246 seconds]
daneb has quit [Remote host closed the connection]
fowlduck has quit [Remote host closed the connection]
daneb has joined #crystal-lang
daneb has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
ozra has joined #crystal-lang
daneb has joined #crystal-lang
waj has quit [Quit: waj]
NeverDie_ is now known as NeverDie
daneb has quit [Remote host closed the connection]
fowlduck has quit [Remote host closed the connection]
fowlduck has joined #crystal-lang
<ashleyis> yay on 895 :D, you guys are too fast
waj has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<crystal-gh> [crystal] yui-knk opened pull request #901: Minor fix of block space (master...fix/space2) http://git.io/vtizz