jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
perks has joined #crystal-lang
matp has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
mkl0501 has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
pduncan has quit [Ping timeout: 250 seconds]
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
pawnbox has quit [Remote host closed the connection]
xmgx has quit [Remote host closed the connection]
mkl0501 has joined #crystal-lang
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
kulelu88 has quit [Quit: Leaving]
pataphysics has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
bjz has quit [Ping timeout: 265 seconds]
bjz has joined #crystal-lang
Philpax has quit [Ping timeout: 244 seconds]
Philpax has joined #crystal-lang
onionhammer has quit [Ping timeout: 265 seconds]
onionhammer has joined #crystal-lang
perks has quit [Quit: perks]
pawnbox has quit [Remote host closed the connection]
soveran has joined #crystal-lang
woodruffw has quit [Ping timeout: 260 seconds]
soveran has quit [Ping timeout: 252 seconds]
soveran has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Philpax has quit [Ping timeout: 244 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Excess Flood]
woodruffw has joined #crystal-lang
woodruffw has quit [Excess Flood]
woodruffw has joined #crystal-lang
woodruffw has quit [Excess Flood]
woodruffw has joined #crystal-lang
woodruffw has quit [Excess Flood]
woodruffw has joined #crystal-lang
<BlaXpirit> jeromegn, it's actually even simpler. (0...size).map { |i| String.new(ptr[i]) }
Philpax has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mark_66 has joined #crystal-lang
bjz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
gewo has quit [Quit: WeeChat 1.0.1]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 244 seconds]
soveran has joined #crystal-lang
tomchapin has joined #crystal-lang
tomchapi_ has quit [Ping timeout: 244 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondi has joined #crystal-lang
ponga has joined #crystal-lang
_jaitaiwan has joined #crystal-lang
<_jaitaiwan> Hey guys, I'm attempting to use Types in a way I think is still potentially not decided on how crystal types should work
<_jaitaiwan> I have a class B and C which inherits from A and have a variable which is [] of A. Unfortunately I get compile time errors trying to populate the array with B & C classes even though they both inherrit from A. Can anyone suggest some alternatives?
<RX14> _jaitaiwan, i don't think crystal supports that yet, unfortunately. I think you have to wait until the next release and that should be fixed.
<_jaitaiwan> Next release as in 1.0 or 0.19?
<RX14> 0.19, hpefully
<RX14> it's an annoying limitation
<RX14> it'll be gone before 1.0 at least
<_jaitaiwan> Fair enough... bit of a shame considering it [seems to me to be] a fairly straight forward concept in the programming world
<_jaitaiwan> If I understood the AST stuff I'd dig right in and make it happen myself
<_jaitaiwan> Any idea where one might get started implementing this? Happy to help where I can
<RX14> well i think the problem is actually how to represent it on the LLVM side
<BlaXpirit> _jaitaiwan, ??? https://carc.in/#/r/17hk
<RX14> i swear that didn't work...
<RX14> or maybe it was just Int and Object these days
<BlaXpirit> it was probably abstract or generic types
<RX14> oh yeah
<RX14> well making A abstract works
_jaitaiwan has quit [Ping timeout: 264 seconds]
<BlaXpirit> RX14, ayy, your last message makes for a good RFC :D
<RX14> yeah it probably does
<BlaXpirit> "having a standard "assertion failed" exception that all spec libraries use."
<BlaXpirit> unfortunately power_assert probably won't be in standard lib, we have to live with it
<RX14> because spec's assertionfailed exception that it special cases can't be required without the rest of spec
<BlaXpirit> but improving it is still nice. i should get into it one day :/
<RX14> i actually don't know why power_assert takes so long
<RX14> because it shouldn't be typing a load of stuff
<RX14> each macro expantion basically initializes one class which should be typed once if the compiler is smart
<RX14> the macro expantion itself shouldn't take long
<RX14> *sigh*
pduncan has joined #crystal-lang
<jeromegn> BlaXpirit: thanks for the LibC::Char** -> Array(String) tip :)
pduncan has quit [Ping timeout: 250 seconds]
<BlaXpirit> RX14, found another weirdness https://gist.github.com/72ef9c211749b00faa72784091998d64#file-out_b-txt-L43 - doesn't break down the information for some reason
<RX14> great
<BlaXpirit> !(method(x) == y) works fine but !method(x) does this
pawnbox has quit [Remote host closed the connection]
<BlaXpirit> actually, although it works, it shows a wrong representation. assert !(1 === JSON.parse("1")) -> !1 === JSON.parse("1")
mkl0501 has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
xmgx has joined #crystal-lang
matp_ has joined #crystal-lang
matp has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
perks has joined #crystal-lang
perks has quit [Client Quit]
<FromGitter> <splattael> Is there a way to determine a block's _return type_ during *compile* time? https://carc.in/#/r/17hq
<FromGitter> <splattael> Obviously, we already can determine argument's type during compile time
<BlaXpirit> splattael, https://carc.in/#/r/17hr
<FromGitter> <splattael> BlaXpirit, isn't `typeof({{yield}})` the same as `{{yield}}.class`?
<FromGitter> <splattael> Both are runtime, aren't they?
<BlaXpirit> >> a = (true ? 5 : "5"); {typeof(a), a.class}
<DeBot> BlaXpirit: # => {Int32, Int32} - https://carc.in/#/r/17hs
<BlaXpirit> /optimized
<BlaXpirit> >> a = (5 == 5 ? 5 : "5"); {typeof(a), a.class}
<DeBot> BlaXpirit: # => {(Int32 | String), Int32} - https://carc.in/#/r/17ht
<BlaXpirit> typeof is compiletime.
<FromGitter> <splattael> BlaXpirit, perfect! Thank you :-)
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
mkl0501 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
pawnbox has quit [Ping timeout: 260 seconds]
matp_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<FromGitter> <splattael> BlaXpirit, I'm still struggling with "return types" during compile time :-(
<FromGitter> <splattael> How can I find all `union_types`?
<FromGitter> <splattael> `typeof({{yield}}).union_types` won't work
<FromGitter> <splattael> The thing I want to build is to generate code depending on the block's return type passed to macro
<BlaXpirit> splattael, the only idea i have right now is... more macros!
<BlaXpirit> pass the result of typeof to a macro, and then the macro gets a TypeNode (possibly after calling .resolve) after which u can probably get union_types
<BlaXpirit> nope, doesnt work
<FromGitter> <splattael> yes, I tried: https://carc.in/#/r/17hz
matp has joined #crystal-lang
<RX14> macro expantion happens before type inference iirc
<RX14> the Var macro type doesn't have a type on
<RX14> so it's impossible
<FromGitter> <splattael> But macro can see arguments' types
<RX14> not if they aren't literalsd
<RX14> if you pass a variable into a macro it can't know the type
<FromGitter> <splattael> oh I see
<BlaXpirit> makes sense, i agree that it's impossible
<BlaXpirit> RX14, right now i'm thinking, why does power_assert have its own hierarchy of nodes, when what the compiler gives is already perfectly usable?
<BlaXpirit> and with good rendering (node->code)
<BlaXpirit> another fun thing with power_assert: def f; p rand(); end; assert f == 0 - executes f 3 times
<BlaXpirit> i think it's possible to avoid multiple calls
<BlaXpirit> rewrite the ast to wrap every expression into a function that saves the value for later, and only then execute everything
<BlaXpirit> to me it seems like an obligatory feature. not sure what's worse - the fact that it calls everything multiple times or the fact that the assert output can be different than what was actually compared
<BlaXpirit> easy example to see - def f; p rand(2); end; assert f == 0 - it can fail but show 0 == 0 in the breakdown
mark_66 has quit [Quit: Leaving.]
Renich has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<BlaXpirit> is it possible to create nodes in macros?
soveran has quit [Remote host closed the connection]
<RX14> BlaXpirit, the reason why it needs two representations is because doing any serious computation in macro language is hell
<BlaXpirit> indeed
<RX14> so the best way to do it is to create nodes from the macro AST
<RX14> and yes the calling multiple times is a bug
mhib has joined #crystal-lang
<BlaXpirit> well it's impossible to resolve without a complete rewrite, i dont think
<RX14> impossible to make fast
<RX14> not impossible to solve multiple callings
<RX14> thats easy enough
<BlaXpirit> i'd like to know how
<RX14> uhh
<RX14> only paste once then use macro vars
pduncan has joined #crystal-lang
Renich has quit [Ping timeout: 244 seconds]
Renich has joined #crystal-lang
xmgx has quit [Remote host closed the connection]
kulelu88 has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 258 seconds]
pawnbox has quit [Remote host closed the connection]
matp has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
Renich has quit [Quit: leaving]
mhib has quit [Quit: Leaving]
mkl0501 has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
matp has joined #crystal-lang
soveran has quit [Remote host closed the connection]
bmcginty has joined #crystal-lang
<BlaXpirit> is it possible to create nodes in macros?
<BlaXpirit> RX14, oh yeah, next thing... since userspace power_assert is not fast enough, how about one in the compiler?
soveran has joined #crystal-lang
<RX14> BlaXpirit, that would be much nicer
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<BlaXpirit> because it's a transformation of the AST, maybe a good start would be a separate process that does the transformation, followed by an inquiry to include it in the compiler
<BlaXpirit> process can receive a string and parse crystal code and it will be just the same, right?
pawnbox has quit [Ping timeout: 250 seconds]
soveran has joined #crystal-lang
<BlaXpirit> hah this is ridiculously slow though
<RX14> BlaXpirit, yes
<RX14> which is why the best solution is to do it in the compiler
<BlaXpirit> RX14, i know but i'm saying it's easy to develop a proof of concept this way, and it can be transfered into the compiler unchanged
<BlaXpirit> do you think this is correct?
<RX14> oh yes i misunderstood
sagax has joined #crystal-lang
soveran has quit [Remote host closed the connection]
perks has joined #crystal-lang
sagax has quit [Remote host closed the connection]
<BlaXpirit> RX14, alright, i got something brewing https://gist.github.com/BlaXpirit/b4f150b0d22e9e3ee2dff3bcf8ec8cb5
<RX14> nice
<FromGitter> <alex-lairan> Hi guy's, when I run ```{{ run("./_macro") }}``` puts print when I compile. What I can do to remove print?
<FromGitter> <alex-lairan> My puts look like this:
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57be023a7de2114a7998532d]
<BlaXpirit> I don't understand the problem
<FromGitter> <alex-lairan> When I execute my main program
<FromGitter> <alex-lairan> I have this line: ```{{ run("./_macro") }}```
<FromGitter> <alex-lairan> and `_macro.cr` have these lines: ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57be02f5ce157d1b57a0e20c]
<FromGitter> <alex-lairan> So, when I execute the code, my console have non important messages
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57be032d61f3fa59598a636f]
<BlaXpirit> $routes is defined earlier, right?
<FromGitter> <alex-lairan> yea
<BlaXpirit> alex-lairan, do you by any chance require"./_macro"
<FromGitter> <alex-lairan> :o:
<FromGitter> <alex-lairan> ```require "./Opali/**"```
<FromGitter> <alex-lairan> X)
<FromGitter> <alex-lairan> I'm so stupid :(
<FromGitter> <alex-lairan> XD
<FromGitter> <alex-lairan> thanks !
soveran has joined #crystal-lang
<FromGitter> <alex-lairan> Can i exclude ```_filename.cr``` file?
<FromGitter> <alex-lairan> or I need to include one by one ? ^^
<BlaXpirit> alex-lairan, how about using `*` instead of `**` and using a subfolder
<FromGitter> <alex-lairan> Hum :) why not
<FromGitter> <alex-lairan> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=57be04937c2d3860599e9c30]
<FromGitter> <alex-lairan> Thank you guy :D
<FromGitter> <alex-lairan> I feel soo stupid :3
matp has quit [Remote host closed the connection]
<BlaXpirit> RX14, lol this is almost feature parity, in so little code. https://gist.github.com/BlaXpirit/b4f150b0d22e9e3ee2dff3bcf8ec8cb5
<BlaXpirit> of course there's the vertical lines still
<RX14> thats nice
<RX14> now benchmark it
<RX14> actually
<BlaXpirit> RX14, it would be a ridiculous benchmark cuz external process
<RX14> yeah i guess
<BlaXpirit> and that external process takes very long to compile cuz half the compiler is in it
<BlaXpirit> oh but it's cached so it's not so bad
<BlaXpirit> anyway, benchmarks are not my strong suit. do that if you want
<RX14> really, it's surrounding the assert statement with a macro 100000 times do
<RX14> and timing the compiler
<RX14> vs spec asserts
mgarciaisaia has joined #crystal-lang
<BlaXpirit> in the last few days, so many times have I run into the silly problem that with array[a...b] a must be a valid index
soveran has quit [Remote host closed the connection]
<Papierkorb> Are there already Crystal notebook stickers?
soveran has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
matp has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
willl has joined #crystal-lang
<FromGitter> <mverzilli> @Papierkorb we have some
<FromGitter> <mverzilli> but I guess it's gonna be a bit expensive to ship :P, maybe we can send you a PDF and you have them printed
matp has quit [Ping timeout: 265 seconds]
azrad has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Renich has joined #crystal-lang
pawnbox has quit [Ping timeout: 252 seconds]
<willl> I put crystal into production today because I found out the hitcounter on my site was being blocked by adblockers. https://github.com/will/bitfissionhitcounter/blob/master/src/hitcounter.cr
<BlaXpirit> :)
Dreamer3 has joined #crystal-lang
perks has quit [Quit: perks]
perks has joined #crystal-lang
perks has quit [Client Quit]
Dreamer3 has quit [Quit: Leaving...]
<BlaXpirit> RX14, could you try putting this into the compiler?
<BlaXpirit> or is it too much trouble to take the risk
<RX14> i could, but i have a billion other things to do
<BlaXpirit> right, that too...
<BlaXpirit> there's a funny thing about this
<BlaXpirit> I realize that it's better to make the compile time generation simple, and the runtime doesnt matter
<BlaXpirit> i mean, it's important that it generates code quickly, not that the generated code runs quickly
<BlaXpirit> in your message https://github.com/crystal-lang/crystal/issues/3095#issuecomment-237660749 you say "optimal codegen" but I think it's optimal the wrong way around
<RX14> i don't think so
<RX14> the real cost for the compiler is typing
<RX14> so the less code we gen, the faster it is
<BlaXpirit> so i suggest generating as short code as possible, even if it's inefficient
<RX14> it's cheaper to work it out in the compiler because computation of this kind is cheap
<RX14> it's the inefficiency of marshalling it between different types thats expensive
<RX14> i.e. macro code
<BlaXpirit> oh well, it'll be interesting to benchmark
<RX14> BlaXpirit, well
<RX14> that optimization
<RX14> which is send everything to a variable
<RX14> thats optimal to me
<RX14> i cant think of any shorter code
<BlaXpirit> interesting points of view, but yours seems more plausible to me now
<RX14> compared to everything else a compiler does, adding this is super cheap
<BlaXpirit> but the number of asserts will be huge!
<RX14> if you ahve that meany asserts you have that meany _more_ typings
<BlaXpirit> there is another way to look at this, what if a runtime function is introduced, and the only generated code is the function call with a minimal set of data
<BlaXpirit> what do you think
<RX14> i thought of that
<RX14> but the cost is in marshalling the data
<RX14> by the time you've collected the data and serialized it for the rtuntime
<RX14> you might as well construct the string
<BlaXpirit> again you appear correct
Philpax has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
<BlaXpirit> who needs video games, this is the real fun
<BlaXpirit> i just dont like the part of implementing an actual assert statement
perks has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<RX14> well i need sleep
Philpax has joined #crystal-lang
perks has quit [Quit: perks]