<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/v2NI1
<crystal-gh>
crystal/master bcafd9b Ary Borenszweig: Call error: suggest that there might be a typo in a method whose name is similar to 'initialize'. Fixes #2271
<umurgdk>
Is there any documentation about how to use Type+
<umurgdk>
what + means
<travis-ci>
crystal-lang/crystal#bcafd9b (master - Call error: suggest that there might be a typo in a method whose name is similar to 'initialize'. Fixes #2271): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/113892103
Ven has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/v2NtQ
<crystal-gh>
crystal/master 46ba2ec Ary Borenszweig: Lexer: inside macros, make sure to parse `#{{{` as `#{ {{`
<jhass>
umurgdk: compiler internal relic, will eventually go, safe to ignore in any case
<jhass>
it just means the type has child types
<umurgdk>
jhass: heh anyway i solve the problem. but it was a bit strange
<umurgdk>
i have this class named String inside of Parsec module
<umurgdk>
but compile finds standard String even i type Parsec::String
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<jhass>
sounds unlikely
<umurgdk>
i renamed it to StringParser and it solved :D
<jhass>
>> module Parsec; class String; end; end; s = Parsec::String.new; s.is_a? String
<umurgdk>
after i changed the classname it find other issues with types after i solved them it worked. maybe it was selecting standard String because it can't compile other stuff i don't know o.O
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<umurgdk>
does crystal compiler code elimination? i mean even i implement many helpers in my library if developer don't use them compiler get rid of unused things?
<jhass>
kind of, yes. methods are typed on call, not on definition, so methods not called won't even generate llvm IR
<umurgdk>
jhass: cool thanks
Ven has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
<RX14>
jhass, is there any sort of dead code elimination that could affect benchmarking?
<jhass>
why would it affect benchmarking?
<jhass>
I don't think there's any done by crystal on that granular level, that's more a LLVM optimizer job
<RX14>
well, if your whole code gets optimised to nothing because the value is never used, then your benchmark is void
<jhass>
I'd argue then your benchmark is buggy ;)
<RX14>
i'd argue the benchmark harness would be buggy
<jhass>
but sure, LLVM does that kind of elimination
<RX14>
JMH has a class called blackhole which deals with this
zeno_ has quit [Ping timeout: 252 seconds]
krtv` has joined #crystal-lang
<umurgdk>
can i define custom operators for classes (not overloading new ones)?
<jhass>
you can't make up new syntax, but most if not all operators are just method calls
<jhass>
and interpret all syntax in interesting ways if you use it in a macro call I guess
<umurgdk>
im writing a parser combinator library
<umurgdk>
as far as i would be able to do like this: string("ruby") | string("crystal")
<umurgdk>
but if i had custom operators (infix methods with custom precedence i would be able to write + / ! etc. without paranthesis or temp variables
<RX14>
+ and / should be methods
<jhass>
| too
<RX14>
yeah
<umurgdk>
is there any precedence table i can check
<jhass>
not aware of any yet
<jhass>
I'd expect it to be similar to ruby's though
<umurgdk>
ok i will write a script to test :)
krtv` has quit [Ping timeout: 244 seconds]
krtv` has joined #crystal-lang
krtv` has quit [Ping timeout: 252 seconds]
krtv` has joined #crystal-lang
krtv` has quit [Ping timeout: 250 seconds]
fowlduck has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]
krtv` has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shama has joined #crystal-lang
krtv` has quit [Ping timeout: 276 seconds]
krtv` has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
krtv` has quit [Ping timeout: 244 seconds]
shadeslayer has quit [Read error: Connection reset by peer]
krtv` has joined #crystal-lang
krtv` has quit [Ping timeout: 268 seconds]
ragmaanir has joined #crystal-lang
umurgdk has quit [Read error: Connection reset by peer]
umurgdk has joined #crystal-lang
Gasher has joined #crystal-lang
shama has quit [Remote host closed the connection]
shama has joined #crystal-lang
umurgdk has quit [Remote host closed the connection]
umurgdk has joined #crystal-lang
sp4rrow has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
robacarp has quit [Ping timeout: 244 seconds]
Gasher has quit [Quit: Leaving]
robacarp has joined #crystal-lang
bcardiff has joined #crystal-lang
Ven has joined #crystal-lang
bcardiff has quit [Client Quit]
Gasher has joined #crystal-lang
ready has joined #crystal-lang
<ready>
undefined method 'to_i' for Nil
<BlaXpirit>
ready, indeed
<ready>
hi, how i can convert env.params["sid"] to int?
<BlaXpirit>
ready, not enough information
<ready>
i get env.params["sid"] from request
<ready>
and i want convert to int
<BlaXpirit>
ready, that must be some library that you're using?
<ready>
but seems dont exist safe method for converting
<BlaXpirit>
ready, no, you just probably haven't read any tutorial about Crystal
<BlaXpirit>
jhass, :D ran into this recently as well
<jhass>
anyway, still proves the point
<jhass>
null is parsed to nil
<BlaXpirit>
ready, i'm sorry that i'm so rude. but seriously that Kemal library will not be a good starting point
<BlaXpirit>
jhass, still if I want to read request args I need a method that returns String and nothing else
<ready>
why
<jhass>
ready: the proper solution is .try &.to_i or .try &.to_i? if you want to be exception free and handle the case it's nil
<ready>
dont work
<BlaXpirit>
jhass, no, that's not proper. that's the best workaround.
<ready>
undefined method 'to_i' for Bool
<jhass>
BlaXpirit: ssssh
<jhass>
relax
<jhass>
ugh
<BlaXpirit>
I would guess.... (params["a"] as String).to_i
<BlaXpirit>
I seriously don't remember ever using .try , forgot it even existed
<jhass>
or exception free, foo = request.params["foo"]; foo = foo.to_i? if foo.is_a? String; bad_request unless foo.is_a? Int32
<BlaXpirit>
jhass, pretty sure that won't work
<jhass>
bad_request is pseudo for sure
<BlaXpirit>
oh I missed the suffix if, sorry
<BlaXpirit>
what a mouthful
<BlaXpirit>
and what it really should be, under proper design: params["a"].to_i; rescue; bad_request
<jhass>
well, I can follow the motivation for having the framework handle application/json vs application/multipart-form-data-whatever for you transparently
fka has joined #crystal-lang
<BlaXpirit>
jhass, problem is the SAME method is used for /resize?width=200&height=200 env.params["width"]
<ready>
working sid = env.params["sid"].to_s.to_i
<ready>
looks shitty
<jhass>
ready: it's the least proper solution, yes
<jhass>
BlaXpirit: let's not play that game, thanks
<ready>
if u find better lib , ping us
<fka>
we still develop kemal and we know it has some issues. PR's are welcome :)
<jhass>
fka: I think you'll win a lot by separating API for body, query and path params
<BlaXpirit>
well, I don't see any good web framework in top 5
<jhass>
the latter too being string only and far more often subject to conversions will make it easier to use
<jhass>
*two
<fka>
actually me and serdar (sdogruyol, the owner of kemal) argued about it many times. but we decided a post and a get parameter with the same key is a bad design itself.
<BlaXpirit>
fka, here I see GET and JSON with the same key
<jhass>
read the backlog for ready's question, it's not about being able to have that