umurgdk has quit [Read error: Connection reset by peer]
umurgdk has joined #crystal-lang
umurgdk has quit [Remote host closed the connection]
bjz_ has quit [Ping timeout: 252 seconds]
<BlaXpirit>
I don't know what's happening. I've tried testing so many things lately and everything fails (on Ubuntu 14.04)
<BlaXpirit>
crystal_lib gives a weird error in compiler source
<BlaXpirit>
crystal-icr builds for a very long time then runs out of memory
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
bcardiff has joined #crystal-lang
<jeromegn>
BlaXpirit: the custom travis config is because you need llvm-dev?
<BlaXpirit>
jeromegn, uh yes
<BlaXpirit>
jeromegn, actually custom config because crystal travis config is broken on ubuntu 14.04
<BlaXpirit>
or maybe it's sudo: required that does it
<jeromegn>
probably not the issue but.. whenever I had problems like that in Ruby, it was due to the load order of files when loading with a glob. the files were ordered differently between ubuntu and os x, I had to sort the files before requiring them.
<BlaXpirit>
what llvm is used to build crystal ubuntu packages???
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 246 seconds]
trapped has joined #crystal-lang
Philpax has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
pawnbox__ has joined #crystal-lang
pawnbox_ has quit [Ping timeout: 264 seconds]
pawnbox has quit [Ping timeout: 250 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
<splattael>
Is there a way to determine if a var is `uninitialized`?
<splattael>
`uninitialized` vars are "truthy" so a simple if var doesn't work
<BlaXpirit>
splattael, uninitialized vars can have any random value, they are not safe to use and you can't check whether they're initialized
<BlaXpirit>
if you have some doubts about best practices, ask away, but this sounds like a bad idea in the first place
<Papierkorb>
Surprised that crystal even has uninitialized variables
<splattael>
BlaXpirit: thanks. You're right, it is a bad idea. I'm porting some clunky Java code to Crystal and try to stay as close as possible to the original (clunky) code.
<splattael>
All I want (or even have to) is to avoid nilable values.
<splattael>
...which existed in original Java code _everywhere_
<crystal-gh>
[crystal] asterite opened pull request #2346: Compiler: add `--check` flag to formatter tool. Fixes #2328 (master...feature/format_check) https://git.io/vaHja
<BlaXpirit>
Array(JSON::Type) it is
<BlaXpirit>
jeromegn, so your code can be replaced with json[0].as_h
<jeromegn>
indeed
<jeromegn>
thanks BlaXpirit :)
<asterite>
splattael: nil should be used for that (means "absence of value")
<asterite>
`uninitialized` is mostly for low-level code that needs to be performant, or for stack-allocated byte buffers
<asterite>
splattael: I guess in your case you don't need to do nil checks with `if var`... in Java every variable that has a class type can also be null, so you have to be very defensive all the time if somebody slips a null. In Crystal there's no need for that
Gasher has quit [Quit: Leaving]
Gasher has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
pawnbox has joined #crystal-lang
pawnbox__ has quit [Ping timeout: 250 seconds]
<splattael>
asterite: yes, this is the point. The Java code base has nilable types everywhere ;) Adding null object patterns should solve this for Crystal :-)
<splattael>
for example: empty profile will be a null object instead of just `null`.
<splattael>
Crystal has already caught possible bugs during porting. This is nice!
<asterite>
splattael: I think I would still use `nil` in that case, it's simpler to deal with rather than having to create a full blown null pattern object, and the compiler will tell you when you try to use a nilable value incorrectly (just my opinion, though)
mgarciaisaia has left #crystal-lang [#crystal-lang]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vaQuB
<crystal-gh>
crystal/master acc27dc Ary Borenszweig: Compiler: fixed regression of captured block returning a more specific type than the specified return type. Fixes #2347
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vaQzS
<crystal-gh>
crystal/master 4ff8581 Ary Borenszweig: Fixed a couple of typos [ci skip]
bcardiff_ has joined #crystal-lang
bcardiff has quit [Ping timeout: 264 seconds]
bcardiff_ is now known as bcardiff
<splattael>
asterite: I see, but would handle this situation during tests with `minitest`. `if var` in tests seems strange. Does it also work with `assert var; assert_equal "foo", var.uid`?
<travis-ci>
crystal-lang/crystal#acc27dc (master - Compiler: fixed regression of captured block returning a more specific type than the specified return type. Fixes #2347): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/117756999
rok_ has joined #crystal-lang
<asterite>
No, it'll give you the same error. In a test you can probably use var.not_nil!.uid. The `not_nil!` is basically a runtime assertion
<splattael>
Aah, perfect!
<splattael>
asterite: thank you :-)
ARM9 has joined #crystal-lang
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vaQDG
<crime>
yeah, REPLs are pretty nice. SLIME for example is a good one for lisp
<ARM9>
wrong, it's because they disregarded incremental compilation from the get go like rust. on the site there's a post mentioning a compiler rewrite that'll take it into account
<RX14>
how will incremental compilation help a REPL?
<ARM9>
not having to rebuild anything
<ARM9>
unless you modify some old piece of code
<RX14>
that's not really how it works i don't think
<ARM9>
feel free to elaborate
pawnbox has quit [Ping timeout: 244 seconds]
<RX14>
incremental compilation means compiling only the minimal amount of changes, it's aimed to make compiler times unneccesary
<RX14>
a REPL is more like incremental execution
<RX14>
which isn't possible in crystal
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
<donpdonp>
what method is called on value in "#{value}" ?
<RX14>
to_s I think
<donpdonp>
i thought is was #to_s but its not working :(
<tilpner>
Why does a "Hello World" binary link against libpcre?
<RX14>
because it includes the standard library, I think there's a cxompiler flag to stop that
<tilpner>
Oh, so it doesn't matter which part I "require", it will include everything anyways? Is the standard library pre-compiled and is that the reason for this?
<RX14>
tilpner, the stdlib isn't precompiled
<RX14>
but there is a "prelude"
<RX14>
which is required into every program
<RX14>
otherwise you would have to require too many things
<RX14>
like having to require the gc and default object methods
<tilpner>
So if I copy src/prelude.cr, remove 'require "regex"', and use that as a prelude, libpcre would not be linked?
* tilpner
goes and tries that.
<RX14>
maybe
<RX14>
you can use crystal build --prelude
<tilpner>
Nope, no success here. :/
<tilpner>
Maybe regex is required somewhere else.
bcardiff has quit [Quit: bcardiff]
shevy has left #crystal-lang ["I'll be back ... maybe"]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ragmaanir has joined #crystal-lang
rok_ has quit [Quit: rok_]
emancu has quit []
bcardiff has joined #crystal-lang
edjsu has quit [Quit: WeeChat 1.2]
ragmaanir has quit [Quit: Leaving]
bcardiff has quit [Quit: bcardiff]
trapped has quit [Ping timeout: 276 seconds]
Philpax has joined #crystal-lang
<RX14>
jokke, you around?
edjsu has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 252 seconds]
<BlaXpirit>
tilpner, yeah it's probably all throughout the code
<BlaXpirit>
cant get rid of regex
Gasher^ has joined #crystal-lang
<tilpner>
BlaXpirit - I couldn't get a binary that I compiled on Arch to work on Debian, but I can compile the HelloWorld example on Debian. Why is that?
Gasher has quit [Ping timeout: 252 seconds]
<BlaXpirit>
tilpner, does it say anything when it fails>?
<tilpner>
"./hello: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory"
<BlaXpirit>
uh ok, so that lib is not available
<BlaXpirit>
tilpner, what does `ls /usr/lib/libpcre.*` say on debian?
<tilpner>
I really don't know what's going on. Give me a second.
<tilpner>
On Debian: crystal run hello.cr
<tilpner>
>> Error: you've found a bug in the Crystal compiler.
<tilpner>
On Debian as root: crystal run hello.cr >> Hello Crystal!
<tilpner>
It's just puts "Hello Crystal!"
<tilpner>
Using the Arch-compiled binary on Debian, as root or normal user: ./hello: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
<BlaXpirit>
tilpner, yeah I understand, but please run `ls /usr/lib/libpcre.*` on debian
<BlaXpirit>
tilpner, are you sure hello.cr isn't owned by root?