Philpax has quit [Read error: Connection reset by peer]
Philpax has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 244 seconds]
willl has quit [Quit: Connection closed for inactivity]
shawn42 has joined #crystal-lang
Philpax has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
<crystal-gh>
[crystal] DougEverly opened pull request #2479: JSON::Any as_type? methods return Type or Nil (master...nilable_as_methods) https://git.io/vwOCZ
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 250 seconds]
mgarciaisaia has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
sp4rrow has joined #crystal-lang
broz has quit [Remote host closed the connection]
sp4rrow has quit [Client Quit]
mgarciaisaia1 has joined #crystal-lang
pawnbox has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 260 seconds]
wmoxam has quit [Remote host closed the connection]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
kulelu88 has quit [Quit: Leaving]
ozra has quit [Ping timeout: 250 seconds]
soveran has joined #crystal-lang
wmoxam has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
<nwmcsween>
is it possible to declare an instance variable from all possible names within an enum?
<nwmcsween>
instance variables
<nwmcsween>
something like instance_variable_set from ruby
mgarciaisaia has joined #crystal-lang
trapped has joined #crystal-lang
<nwmcsween>
is there a list of types within crystal?
<nwmcsween>
what is a block type?
<nwmcsween>
proc I guess
mgarciaisaia has left #crystal-lang [#crystal-lang]
pawnbox has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
zeno has joined #crystal-lang
zeno is now known as Guest30306
Guest30306 has quit [Quit: 离开]
zeno_ has joined #crystal-lang
TheLemonMan has joined #crystal-lang
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
<zeno_>
https://play.crystal-lang.org/#/r/wwm I tried to realize a calculator, but get a type problem now, how to solve this? Maybe I need to define a new struct?
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
brunto has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
<TheLemonMan>
zeno_, try to think about the type you want and then look at the type you have
<TheLemonMan>
you want exp to be either a Number or a Array(Number|String)
<TheLemonMan>
and when you access via [] the exp parameter the type system infers that e{1,2} is going to be a Number|String
<TheLemonMan>
and then you feed a Number|String into 'calc' again, which widens the exp to String|Number|Array(Number|String)
<TheLemonMan>
lo and behold, a String is not a Number so you reach the else arm of the if, you deference the string with [] and end up with a Char
<TheLemonMan>
the type widens again to include Char and the story mentioned above happens until you try to deference a Char with [] -> 'undefined method '[]' for Char'
dsounded has joined #crystal-lang
<zeno_>
Yeah, I understood it. So I need to define a new struct? or any else better solutions?
<TheLemonMan>
it depends on what your goal is
<TheLemonMan>
if you want to build a rpn calculator then you should use the shunting-yard algorithm
Philpax has joined #crystal-lang
<TheLemonMan>
otherwise, if you just want to build a function that handles [op, arg1, arg2] you could just drop the eval in the else branch
brunto has quit [Ping timeout: 246 seconds]
mark_66 has joined #crystal-lang
brunto has joined #crystal-lang
brunto has quit [Quit: leaving]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
jeromegn has quit [Ping timeout: 244 seconds]
jeromegn has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
dsounded has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
jeromegn has quit [Ping timeout: 268 seconds]
jeromegn has joined #crystal-lang
x0f_ has quit [Ping timeout: 244 seconds]
ponga has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<zeno_>
Thanks, I want to realize a Lisp interpreter
<TheLemonMan>
zeno_, you might want to follow the make-a-lisp thing
pawnbox has quit [Remote host closed the connection]
<TheLemonMan>
zeno_, type inference strikes again :)
<TheLemonMan>
v1, v2 = calc(e1), calc(e2)
<TheLemonMan>
as you can see, exp might faill all the if tests and return nil
<TheLemonMan>
try adding a return 0 at the end and it'll magically compile :) but that's a workaround, not a solution
<zeno_>
Well, let me add a return type for this function and try again
<crystal-gh>
[crystal] chocolateboy opened pull request #2480: fix documentation typo: index -> rindex (master...fix-doc-typo) https://git.io/vwOHi
dsounded has joined #crystal-lang
<crystal-gh>
[crystal] ysbaddaden pushed 1 new commit to master: https://git.io/vwO7u
<crystal-gh>
crystal/master 4696a24 chocolateboy: fix documentation typo: index -> rindex
dsounded has quit [Ping timeout: 260 seconds]
<zeno_>
I think return 0 is a solution, compiler find that there's some control branches are still undeclared so function maybe return a Nil, just clearly announced that it will return 0 when missing all the if and case, even if I won't do that forever
<TheLemonMan>
you should instead try to make the function always return a Number
<jhass>
nwmcsween: I don't get the first question. Not quite but you can solve most of those usecases with macro's or the (undocumented I think) object.@var syntax, but usually there's a better way than either. Are you looking for the API docs? See /topic. Not all blocks are turned into Procs, they're rather a compile time language construct. But there's conversion/capturing support to do turn blocks into Procs
<jhass>
and invoke Procs like blocks in methods expecting blocks.
<TheLemonMan>
hmm, it seems you can't pass a function in place of a block
<asterite>
zeno_: https://play.crystal-lang.org/#/r/x1y (you must handle the case where an operand is a String, and when you eval a function you must guarantee the compiler that you are dealing with an array)
<zeno_>
Yeah, I almost understood it, thank you :)
<zeno_>
And try to adapt it...
rocx has joined #crystal-lang
ql6wlld has joined #crystal-lang
soveran has joined #crystal-lang
kfpratt has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
soveran has quit [Ping timeout: 276 seconds]
<rocx>
hey. question about compiling crystal. would there be a simpler way to compile via `g++` or does it need to use `clang`?
<jhass>
gcc/g++ should work just fine
<jhass>
do we hardcode clang anywhere?
<jhass>
I can't remember so
<TheLemonMan>
libclang maybe
<rocx>
iunno. i'm just having a hard time trying to compile it with `make`.
<rocx>
whenever i try to run a simple `make`, it comes up with: g++: error: /void-packages/common/environment/configure/gccspecs/hardened-cc1: No
<rocx>
such file or directory
<jhass>
huh
<rocx>
not having luck trying to figure that out since the most i'm finding is "you need to install gcc-g++".
<jhass>
well that seems more like an OS issue
<rocx>
it probably is and i don't even know where to begin.
<rocx>
besides pestering whoever packages this stuff. wouldn't be a first time i had a flagrant issue with their idea of letting the community package thing with very loose guidelines.
<jhass>
maybe we should move to #voidlinux?
<TheLemonMan>
packaging is tricky since you have to boostrap the compiler
<jhass>
well, that's why we provide pretty self-contained tarballs
<rocx>
jhass: nah. i'll just move to probably something like funtoo or something more people use. void linux's pissed me off many times before.
<jhass>
and ensure the previous version of a compiler can compile the current one
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
<dome22xl>
Have a read i will get more in depth with the next post
dome22xl has quit [Ping timeout: 244 seconds]
trapped has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
ssvb_ has quit [Ping timeout: 268 seconds]
ssvb_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh>
[crystal] asterite opened pull request #2481: Time: honor Daylight Saving and ENV["TZ"] (master...feature/time_dst) https://git.io/vwsFH
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
rok has joined #crystal-lang
pawnbox has joined #crystal-lang
rok has quit [Quit: rok]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vwsjK
<crystal-gh>
crystal/master 0dbcda7 Ary Borenszweig: ENV: allow passing `nil` as a value to delete and environment variable
BlaXpirit has quit [Quit: Bye]
BlaXpirit has joined #crystal-lang
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vwGvp
<crystal-gh>
crystal/master 1c02f9e Ary Borenszweig: Use `$HOME/cache/.crystal` (or others similar) as the default cache dir, and only keep the 10 most recently used directories. Fixes #2435 (#2476)
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/vwGUd
<crystal-gh>
crystal/master 3e440df Ary Borenszweig: Fixed #2468: compiler crash if redefining c-external function with different signature
<travis-ci>
crystal-lang/crystal#1c02f9e (master - Use `$HOME/cache/.crystal` (or others similar) as the default cache dir, and only keep the 10 most recently used directories. Fixes #2435 (#2476)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/124298358