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
havenwood has quit [Ping timeout: 246 seconds]
datanoise has quit [Ping timeout: 272 seconds]
waj has quit [Quit: waj]
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
waj has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: http://git.io/vtLiv
<crystal-gh> crystal/master 703a76d Ary Borenszweig: Fixed #855: instance vars initializers didn't go through the second semantic stage
waj has quit [Quit: waj]
<travis-ci> manastech/crystal#2553 (master - 703a76d : Ary Borenszweig): The build passed.
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 246 seconds]
waj has joined #crystal-lang
NeverDie_ has joined #crystal-lang
NeverDie has quit [Ping timeout: 256 seconds]
NeverDie_ has quit [Read error: Connection reset by peer]
NeverDie has joined #crystal-lang
vikaton has quit [Quit: Connection closed for inactivity]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Ping timeout: 248 seconds]
waj has quit [Quit: waj]
<crystal-gh> [crystal] yui-knk opened pull request #857: [ci skip] Add `extended` to macros hooks (gh-pages...guide/macro) http://git.io/vtteT
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 252 seconds]
daneb has joined #crystal-lang
havenwood has joined #crystal-lang
strcmp1 has quit [Quit: Leaving]
veelenga has joined #crystal-lang
BlaXpirit has joined #crystal-lang
daneb has quit [Remote host closed the connection]
havenwood has quit [Ping timeout: 265 seconds]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 250 seconds]
datanoise has joined #crystal-lang
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
unshadow has joined #crystal-lang
unshadow has quit [Quit: leaving]
datanoise has quit [Ping timeout: 248 seconds]
Ven has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
daneb has joined #crystal-lang
BlaXpirit has quit [Quit: Quit Konversation]
BlaXpirit has joined #crystal-lang
txdv has quit [Quit: leaving]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 246 seconds]
unshadow has joined #crystal-lang
<unshadow> Can some one help me a little with String::Builder ?
<unshadow> I'm trying to do this http://carc.in/#/r/549/edit
<unshadow> I guess I should do it another way XD
<unshadow> nm, got it ;)
unshadow has quit [Quit: leaving]
blaix has joined #crystal-lang
Kilobyte22 has joined #crystal-lang
<Kilobyte22> uh, when compiling on a debian based distro, which packages do i need?
ozra has joined #crystal-lang
<jhass> Kilobyte22: the official crystal package should come with everything you need, I think
<jhass> what do you miss?
<jhass> or well, https://github.com/manastech/crystal/wiki/All-required-libraries should work for debian too
<ozra> Why aren't the llvm deps listed? I just installed every llvm 3.5 and 3.6 dev lib I found to get it out of the way ;-)
<Kilobyte22> jhass: isn't that really outdated?
<Kilobyte22> owait, its from ppa, forgot
<jhass> "Ary Borenszweig edited this page 7 days ago"
<jhass> Kilobyte22: so, let's approach this from the other side, what issue do you run into?
<Kilobyte22> none yet
<Kilobyte22> for some reason i thought the package was massively outdated though
<jhass> 0.7.4 is the latest version
<Kilobyte22> yeah
<Kilobyte22> i didn't look at the version
<Kilobyte22> jhass: doesn't that version contain the bug i reported yesterday though?
<jhass> yes
<Kilobyte22> thats my issue then :P
<Kilobyte22> brb
<jhass> Kilobyte22: you still need it though to build the latest compiler
waj has joined #crystal-lang
<jhass> Kilobyte22: git clone git://github.com/manastech/crystal.git; cd crystal; make
<jhass> and if it that worked alias dcrystal=/wherever/you/cloned/to/crystal/bin/crystal
Kilobyte22 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
Ven has joined #crystal-lang
MrMeowMeow has joined #crystal-lang
<Kilo`byte> there, back
<Kilo`byte> this time using my bouncer
<Kilo`byte> i can't compile crystal
<Kilo`byte> linker complains about missing symbols
<Kilo`byte> that's why i asked for libs
<Kilo`byte> will try again later
<jhass> well, might need stuff from my link then, depends on what symbols are missing
<Kilo`byte> llvm ones, even though llvm 3.5 is installed
<jhass> might need llvm-dev or something on debian
<Kilo`byte> i have llvm-3.5-dev
<Kilo`byte> llvm-dev is 3.4 (I'm on mint, so probably not very latest)
<Kilo`byte> (desktop works fine on arch thanks to your aur package)
<jhass> well, which symbols?
<Kilo`byte> uh... sec
<Kilo`byte> gotta boot laptop
<jhass> well, doesn't need to be now ;)
<MrMeowMeow> maowowow
MrMeowMeow has left #crystal-lang ["WeeChat 1.1.1"]
<jhass> wat
<Kilo`byte> wtf
<Kilo`byte> also it complains about not finding -ledit now
<Kilo`byte> off to package manager i go
<jhass> libedit-dev
<Kilo`byte> yeah
<Kilo`byte> a quick pacapt -Ss edit-dev revealed that
<jhass> haha, pacapt
<jhass> that's nice
<Kilo`byte> great script :P
<Kilo`byte> generally the first thing i install on any non-arch system
<Kilo`byte> oh look it compiled
<Kilo`byte> why is there no install target?
<jhass> because nobody wrote one
<Kilo`byte> how'd i properly install though
<jhass> and at this point we'd probably disagree about how it should look :P
waj has quit [Quit: waj]
<Kilo`byte> like, are there instructions
<jhass> as said, I'd just slap the alias into my .$SHELLrc
<Kilo`byte> ah okay
<Kilo`byte> or a wrapper in ~/bin
<jhass> you can symlink bin/crystal too, yeah
<jhass> it'll do the right think to find the executable and set the stdlib path
<jhass> *thing
<Kilo`byte> oh neat
<Kilo`byte> btw, i am storing a block in an instance var. can i somehow tell it what parameter/return types it needs
<Kilo`byte> because without it does not seem to accept parameters
<jhass> Kilo`byte: yeah, you mean a captured block with &block ?
<Kilo`byte> yeah
<jhass> >> def foo(&block : String -> Bool); block.call("hello"); end; foo do |s| s == "hello"; end;
<DeBot> jhass: # => true - http://carc.in/#/r/552
<Kilo`byte> that's easy
<jhass> parameters -> return type
<Kilo`byte> multiple params would be String, Int32 -> Bool for example, right?
<jhass> right
<Kilo`byte> awesome
<Kilo`byte> now to figuring out how the option parser lib works
<Kilo`byte> apparently my phone has vim installed
<jhass> the specs usually provide some good examples
<Kilo`byte> good idea
<Kilo`byte> i wonder if it supports adding options as result of a certain option being set
<Kilo`byte> kinda looks that way
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<ozra> how do cyou concat to an array? Tried `<<` and `.push`
<jhass> >> a = [1]; a << 2; a
<DeBot> jhass: # => [1, 2] - http://carc.in/#/r/555
<jhass> >> a = [1]; a.push 2; a
<DeBot> jhass: # => [1, 2] - http://carc.in/#/r/556
<jhass> and both work
<ozra> Aha. So I guessed right. Done something else right then..
<Kilo`byte> maybe he means appending contents of one array to another
<Kilo`byte> ah okay
<ozra> Does `Array(SomeClass+)` mean any subtype of SomeClass?
<ozra> else *wrong*. Wow, I think I've slept to little..
<Kilo`byte> who needs sleep ;)
havenwood has joined #crystal-lang
<jhass> yes
<ozra> Kilo`byte: I've slept between 2-4 hours, sometimes not at all for nights, for some years, finally caught up with me X-|
<ozra> jhass: ok, thanks..
<Kilo`byte> ic
<Kilo`byte> just curious, how come?
<ozra> Kilo`byte: Just working too much + sleep disorders deluxe since birth.. Usual crap ;-)
<Kilo`byte> ouch :/
<ozra> Kilo`byte: no point complaining, I've got food every day, running water, no wars :)
<Kilo`byte> jhass: the output of the crystal compiler is standalone, right?
<Kilo`byte> as in, no dependency on crystal
Locke23rus has joined #crystal-lang
<jhass> yeah, just run ldd on the binary to see what it depends on
Ven has joined #crystal-lang
<ozra> In catch-all inits, is this not possible: ` @capacity :: Int = 0`?
<ozra> ?
<Kilo`byte> you shouldn't need the :: Int
<Kilo`byte> the compiler will infer it
<ozra> I realize in crystal you don't have too, I'm still a bit in C++ mode in the head - but I do like specing the types in "solid code".. Ofc. I could do `@capacity = 0'u8` etc. to pick other types.. I guess that will be verbose enough..
<ozra> Bombarding with questions here ;) - how do I `@capacity = max @capacity, count`?
<Kilo`byte> in Ruby that's [@capacity, count].max
<Kilo`byte> not 100% sure if same in crystal
<ozra> ok. I'll check the man instead of being lazy ;)
<jhass> ozra: @capacity = {@capacity, count}.max
<Kilo`byte> >> [1, 2].max
<DeBot> Kilo`byte: # => 2 - http://carc.in/#/r/55a
<jhass> that allocates an array though
<Kilo`byte> or with tuple
<jhass> >> {1, 2}.max
<DeBot> jhass: # => 2 - http://carc.in/#/r/55b
<Kilo`byte> didn't know that works as well
<ozra> No function style to do it?
<jhass> the tuple version doesn't, the code is just transformed
<Kilo`byte> Iearned something new
<jhass> Crystal is Ruby inspired, so as OO as possible ;)
<ozra> jhass: so essentially it's the same as just calling a func (or inlined whatever)
<jhass> yeah
<ozra> jhass: Yeah, starting to realize that, haha. I'm no fan of paradigm lock-in, but I can live with it.
<Kilo`byte> you call a function of the tuple object
<ozra> And the tuple object never "really" exists, right..
<jhass> right
<jhass> max is coming from Enumerable, and that calls each. Tuple.each just generates the yields at compile time
<Kilo`byte> yup
<jhass> >> class Foo; include Enumerable(Int32); def each; yield 1; yield 2; end; end; Foo.new.max
<DeBot> jhass: # => 2 - http://carc.in/#/r/55c
<Kilo`byte> nice!
<jhass> that's pretty much what's happening
<Kilo`byte> great job on that design
<jhass> and most of those calls will probably be optimized away/inlined in release mode
<ozra> `@capacity = {@capacity, count}.max` gives me a long error :-/
<Kilo`byte> where is that code?
<Kilo`byte> initialize?
<Kilo`byte> try giving count a type
<ozra> jhass: weird.. Kilo`byte - ok
<Kilo`byte> or yeah, actually call the function
<jhass> idk, that works
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Kilo`byte> the param types are defined by how a function is called
<Kilo`byte> if you don't call it, it can't infer types
<Kilo`byte> you then need to explicitly specify them
Ven has joined #crystal-lang
tlifffreenode_ has joined #crystal-lang
tlifffreenode_ is now known as tliff
<ozra> Hmm... I'm learning by the line here, and am having some more problems, if you'd care to look at some stub code: Kilo`byte
<ozra> Or anyone else..
<ozra> jhass: ? ^
<tliff> okay, I might be doing something really stupid here, but is it possible to monkey patch Float?
<ozra> Ignore that - I just made a plain stupid thing ;-)
<ozra> Yeay, working. Sorry for asking presumtiously. I'm just on my toes thinking I'm gonna hit a compiler bug regarding generic inheritance. Well, did not :-D
<tliff> oh, it is
<jhass> ozra: just don't ask to ask, come straight with your question and whoever with an answer is around will respond ;)
<jhass> tliff: yup, you can
<ozra> jhass: cool
bcardiff has joined #crystal-lang
<jhass> >> struct Float; def the_answer?; self == 42.0; end; end; 42.0.the_answer?
<DeBot> jhass: # => true - http://carc.in/#/r/55s
<tliff> jhass: nice, thank you
ponga has joined #crystal-lang
NeverDie has joined #crystal-lang
datanoise has joined #crystal-lang
waj has joined #crystal-lang
<ozra> I don't see anything on for range loops in manual - use map instead?
daneb has quit [Remote host closed the connection]
<jhass> .each, .map etc
<jhass> .upto, .downto, .to
<jhass> >> 1.upto(5) {|i| print i }
<DeBot> jhass: 12345 - http://carc.in/#/r/55t
<jhass> >> 5.to([1, 10].sample) {|i| print i }
<DeBot> jhass: 5678910 - http://carc.in/#/r/55u
<jhass> >> 5.to([1, 10].sample) {|i| print i }
<DeBot> jhass: 54321 - http://carc.in/#/r/55v
<ozra> Hmm, why no "for x, i in list"? Seems much terser and clearer then "list.each do |i, x|"?
<crystal-gh> [crystal] rhysd opened pull request #859: Add Array#transpose (master...array-transpose) http://git.io/vtYVf
<ozra> is `{|x| ...}` same as `do |x| ...` ?
<Kilo`byte> back
<Kilo`byte> ozra: yes
<Kilo`byte> by convention you generally use {} for one-liners and do ... end for multiple lines
<ozra> Kilo`byte: alright.
<ozra> What about that 'for' above - is it missing completely? I saw it in macros?
<Kilo`byte> thats intentional
<Kilo`byte> actually i am not sure if there was a for thingy. but i'd not use it if there was one
<ozra> Kilo`byte: I just find it clearer then the do and pipes construct...
<Kilo`byte> this actually originates from functional programming where (which is a great concept)
<Kilo`byte> s/where /
<Kilo`byte> it takes a while to get used to, but once you get to that point you don't want back
DeBot has quit [Quit: Crystal IRC]
<Kilo`byte> which makes me curious, are all those manipulations lazy?
DeBot has joined #crystal-lang
<Kilo`byte> in ruby they aren't
<ozra> Kilo`byte: Yeah, I realize that, I enjoy functional too - but when doing imperative, I just want to express things that looks the clearest.. many cases where I would define/use something functionally, I must instead make it a member of (not always very logic) class... Well, in any event - I have coded like that for years in JS etc - and yes - I've gone back! ;-)
<Kilo`byte> jhass: i gotta remember that one
<ozra> jhass: Can one leave a comment, even though it's closed, or is that pointless?
<jhass> no, it's not pointless
<jhass> no, I don't see any real prospects of convincing anybody otherwise ;)
<Kilo`byte> how do i mark a function as generic?
blaix has left #crystal-lang [#crystal-lang]
<jhass> simply type restrict to a free var
<jhass> or don't type restrict at all
<Kilo`byte> well, what i basicly want is a function that accepts a block with certain parameter types but idgaf about the return value of the block
<Kilo`byte> if i fix it to Nil i always have to make sure the block returns Nil
<Kilo`byte> which is annoying when writing the block
<Kilo`byte> actually this may be a good place to use _
<ozra> jhass: Left a comment, and can only cross fingers and hope :-)
<Kilo`byte> uh what type is passed to the block for String#each_char
<Kilo`byte> Char or String
<jhass> >> def foo(&block : String ->); block.call("test"); 1; end; foo &.upcase; foo &.size;
<DeBot> jhass: # => 1 - http://carc.in/#/r/55w
<jhass> just don't specify any :P
<jhass> and each_char should yield Char's
<Kilo`byte> weird. then i don't understand why this isn't working
<ozra> is there any performance hit to making a reference nilable? Or, I'm guessing, it's just a matter of safety ensuring they must be non-nil by default?
<Kilo`byte> ozra: you cannot directly use a nilable type
<Kilo`byte> you need to do a nil check or you get a compile time error
<Kilo`byte> jhass: uh, can i do debug prints in a spec?
<Kilo`byte> i don't seem to see any output from them
<ozra> Kilo`byte: Ok, that's great! I only had to make two instance vars nilable to be able to pass self from initialize().. But they're not ever used unitialized. The constraint should be able to solve in the compiler - since all facts are given at that point. But this works :)
<jhass> Kilo`byte: uh, I'd expect so
<Kilo`byte> okay... then this method is not called...
<ozra> Are there any magic params for blocks or anything? like `it`, when not specifying |some–param|?
<jhass> I don't follow?
asterite has joined #crystal-lang
<asterite> ozra: you can use &.: http://play.crystal-lang.org/#/r/561
ejohnson has quit [Quit: Connection closed for inactivity]
asterite has quit [Quit: Page closed]
<ozra> asterite: Ah, super cool :) great for one liner situtations like that, I just might live without for anyway :)
waj_ has joined #crystal-lang
waj has quit [Ping timeout: 256 seconds]
waj_ is now known as waj
aemadrid has joined #crystal-lang
veelenga has quit [Quit: Page closed]
ponga has quit []
jtarchie has joined #crystal-lang
<ozra> Any way of declaring a method with some attribute like @[Flatten] or @[InlineCalls], or a @[AlwaysInline] at specific call sites? (That is, I want to say that all calls in this method should be inlined, instead of saying that it is an inlinable method)
<ozra> (or preferably at specific call sites)
Ven has quit [Disconnected by services]
Ven_ has joined #crystal-lang
shama has joined #crystal-lang
<waj> ozra: there isn’t any attribute right now. Do you need to inline even in non-release mode? I wonder why do you actually need this.
<ozra> waj: No I don't need to in non release. What I want is basically to add a small intro and outro to all defs of subclasses - now done by calling them from a def in the "mother class". Could probably be done by macros too. They might not be considered for inlining because of their size, but the use is just as I said - boilerplate code they all need..
<ozra> all defs of a specific name that is - not _all_ defs..
<waj> ok, actually… there IS an attribute: AlwaysInline
<ozra> right, I'm just trying to avoid it at the sub class implementations, since they will be count less ;-)
<waj> just add @[AlwaysInline] to your methods and LLVM should do the rest
<waj> oh… sorry, I just re-read your question
<ozra> Well, it ain't no biggie - it might even be faster without inlining, but got curious :)
<crystal-gh> [crystal] asterite closed pull request #857: [ci skip] Add `extended` to macros hooks (gh-pages...guide/macro) http://git.io/vtteT
daneb has joined #crystal-lang
<Kilo`byte> just curious, can i run arbitrary code compile time in macros?
<jhass> Kilo`byte: kinda, you can launch an external process whose stdout is the result of the macro
<Kilo`byte> oh neat
<Kilo`byte> yeah, just looked at the compiler code
<Kilo`byte> i may not even need a macro function
<Kilo`byte> i can just inline that
<jhass> if you want your program to include the compiler ;)
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Kilo`byte> jhass: nah, i mean using {{ stuff }}
<Kilo`byte> instead of a full blown macro
husanu5 has joined #crystal-lang
<Kilo`byte> jhass: speaking of which, can i turn a StringLiteral into an IntLiteral or w/e its called
<willl> I was a bit surprised that inject(&.+) doesn't work as a short hand for summing an array http://carc.in/#/r/56j
<jhass> Kilo`byte: mmh .id might work
<jhass> >> {{"123".id}}.class
<DeBot> jhass: # => Int32 - http://carc.in/#/r/576
<jhass> willl: yeah, that's why we got Enumerable#sum though
<Kilo`byte> jhass: ah yup
asterite has joined #crystal-lang
<asterite> willl: there's also the thing that to_proc in ruby is magic, it returns a proc with arity == -1
<willl> that's quite the arity
<asterite> for example you can do :length.to_proc and :+.to_proc... but length has no arguments and + has arity 1
<asterite> willl: haha, right :)
<jhass> -1 is one optional argument iirc
<jhass> arity's return value is always confusing :/
<asterite> Ruby is magic
<asterite> I think -1 is splat (*)
<jhass> mh
<jhass> I guess the proc being generated is quite literally proc {|receiver, *args| receiver.public_send(self, *args) }
husanu5 has quit [Remote host closed the connection]
<Kilo`byte> yeah, ofc such a thing does not work in a language like crystal
asterite has quit [Ping timeout: 246 seconds]
waj has quit [Quit: waj]
waj has joined #crystal-lang
meow has joined #crystal-lang
<Kilo`byte> can i figure out compile time if i am in release configuration (in macros)?
<jhass> uh, I don't think so
<jhass> and I don't think it's a good idea to differentiate
<meow> exit
meow has quit [Client Quit]
<Kilo`byte> i was going to set a different default log level for a logger depending on config
<Kilo`byte> in release mode you usually don't want debug messages by default
<willl> there's a trick
<jhass> hehe
daneb has quit [Ping timeout: 248 seconds]
<jhass> well it only works in the typeof I think
<jhass> it's never executed
<jhass> Kilo`byte: reminds me that we still can't set ifdef flags with -Dfoo or something :/
daneb has joined #crystal-lang
<Kilo`byte> :/
<Kilo`byte> that would actually have been useful
<Kilo`byte> also reminds me that i gotta write a makefile for my project
<Kilo`byte> jhass: also, just saying, i can run arbitrary commands on your server over carc.in
<jhass> Kilo`byte: yeah, what's the issue with that?
<jhass> :P
<Kilo`byte> i am not sure how sandboxed that is, just so you know :P
<jhass> run one that escapes from the sandbox and we'll talk ;)
<Kilo`byte> probably a debugger attached
<jhass> nah, just modern kernel features
<BlaXpirit> 2 weeks ago i would kill to get some time for fun programming
<BlaXpirit> now i have no inspiration whatsoever
<Kilo`byte> jhass: uh, that interests me
<Kilo`byte> can you throw me some pointers?
<jhass> BlaXpirit: rack port, rake port, slim port, oga port
<BlaXpirit> I don't do ports of Ruby things
<jhass> BlaXpirit: why not?
<BlaXpirit> I don't know Ruby ecosystem at all, and I am not interested in it anyway
<Kilo`byte> jhass: bad. i'd have expected no less than 0x7D28F28A
<BlaXpirit> and probably not enough knowledge of both languages, anyway
<Kilo`byte> although we both probably run 64 bit systems and not 32
<jhass> okay let me repharse then: webframework <-> http/application server interface & common tools, build tool, template language (that has a non-evaling variant), XML/HTML parser & builder
<jhass> Kilo`byte: carc.in actually runs on 32bit
<Kilo`byte> oh okay
<BlaXpirit> what kind of templating languages does crystal have now?
<jhass> not sure I get the 0x7D28F28A reference
<jhass> BlaXpirit: ECR
<Kilo`byte> can we get haml? xD
<BlaXpirit> jhass, is that just DSL?
<Kilo`byte> (would probably depend on the compiler though)
<BlaXpirit> wait, no
<BlaXpirit> ECR is like macros
<BlaXpirit> if i remember
<jhass> yeah, pretty much
<Kilo`byte> or alternatively something like phps twig
<BlaXpirit> so it's compiletime templates
<jhass> it transforms the code into crystal code building a string
<BlaXpirit> interesting how that works
<BlaXpirit> is it possible to make in userland or has to be built into compiler?
<Kilo`byte> doesn't the compiler expose an API you can use?
<Kilo`byte> :P
<jhass> BlaXpirit: it's stdlib, so userland
<jhass> it does invoke the compiler over a run macro though
<BlaXpirit> I didn't know there was an "eval"
<jhass> it's not really eval
<BlaXpirit> what exactly is it that allows to form code and then compile it?
<jhass> it's "run this process at compile time and use its stdout as result of this macro call"
<BlaXpirit> mm that's pretty nice
<BlaXpirit> but still doesn't completely make sense
<jhass> okay, let's see we can walk through the process
<Kilo`byte> whats the best way to try if i can convert something into an int
<jhass> say you have a file: Hello <%= @world %>
<BlaXpirit> Kilo`byte, responds_to?
<jhass> in hello.ecr
<BlaXpirit> i'd say
<Kilo`byte> nah
<Kilo`byte> "A".to_i will fail "1".to_i won't
<BlaXpirit> well then try rescue
<jhass> you do class HelloTemplate; ecr_file "hello.ecr"; def initialize(@world="World"); end; end;
<Kilo`byte> thats what i was trying to avoid
<BlaXpirit> in python you embrace it. don't know about crystal
* Kilo`byte cringes at the sight of the word 'python'
<jhass> ecr_file generates you a to_s that looks like String.build do |io| io << "Hello"; io << @world; end; end;
<jhass> by calling a program that reads the ecr and prints that to stdout
<jhass> makes any sense?
<BlaXpirit> ye
<BlaXpirit> i'm quite familiar with this kind of stuff
<Kilo`byte> uh how to get an enum value from an int
<jhass> uh
<jhass> >> enum Foo; BAR; BAZ; end; Foo.new Foo::BAR.value
<DeBot> jhass: # => BAR - http://carc.in/#/r/57p
<jhass> \o/
<BlaXpirit> Kilo`byte, this example shows going both ways, in case you're confused
<BlaXpirit> jhass, well, i'm still listening
<jhass> uh, that's all there is to it
<Kilo`byte> ah yeah i see
<BlaXpirit> mainly the "calling program" part
<BlaXpirit> hmm
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
daneb has quit [Read error: Connection reset by peer]
<jhass> note the latter is compiler code
<BlaXpirit> what is ecr/process
<BlaXpirit> where does it come from
<Kilo`byte> wow the "did you mean" part of the compiler is neat
<jhass> like crystal run
<jhass> invoked like I mean
<BlaXpirit> ok
<BlaXpirit> so you make a program that takes templates and outputs code, then you invoke builtin functionality that gets stdout and compiles the code
<BlaXpirit> the concept is clear. thanks, jhass
<jhass> bin/crystal src/ecr/process.cr -- hello.ecr io
<Kilo`byte> what is the best option to spawn a child process?
<Kilo`byte> while not capturing stdout/err
<Kilo`byte> does system() work?
<jhass> should
<jhass> if you want to block
<jhass> it's just a wrapper around Process.run though, which can do whatever
<Kilo`byte> gah Process does not have #uid, #euid etc
<Kilo`byte> and also not the setters
asterite has joined #crystal-lang
daneb has joined #crystal-lang
<Kilo`byte> is there a different class/module that has that?
<jhass> yah, monkey patch them and upstream if you feel they're solid ;)
<Kilo`byte> if not i may just PR it in
<asterite> jhass: there's -D, actually
<jhass> uh, did I miss it?
<asterite> Probably :)
<asterite> I think we added it when we wanted the evented mode to be enabled with a flag
<Kilo`byte> jhass: can i have more than one lib block with same name?
<jhass> Kilo`byte: it's like reopening a class then, yes
<Kilo`byte> neat
<jhass> asterite: btw do I have to pull request -v or do you want to add it to your regular pushes? :P
daneb has quit [Read error: Connection reset by peer]
<asterite> what's -v?
<jhass> --version
<jhass> every single time I try crystal -v before crystal --version ;)
<Kilo`byte> jhass: is there a platform dependent int type?
<jhass> uh
<jhass> BlaXpirit: ^ ;P
<Kilo`byte> aka cs 'int'
<asterite> as an alternative to --version?
<jhass> asterite: alias, yes
<BlaXpirit> jhass what exactly are you pointing to?
<jhass> Kilo`byte's question
<Kilo`byte> yes
<asterite> jhass: I'll do it
<jhass> asterite: <3
<BlaXpirit> Kilo`byte, platform dependent types are currently missing in crystal
<Kilo`byte> kk
<BlaXpirit> and the few that there are, probably are subpar
<Kilo`byte> gotta do that myself then
<BlaXpirit> int is 32 bit on all major platforms
<Kilo`byte> even x84_64
<BlaXpirit> yes
<Kilo`byte> oh okay
<Kilo`byte> my c knowlage is a bit dated
<Kilo`byte> xD
<BlaXpirit> Kilo`byte, do read what i linked. describes C types pretty comprehensively too.
<Kilo`byte> lol, i am too used to scala
<Kilo`byte> i keep writing def <name> =
<Kilo`byte> what exception type should i use for permission denied
<jhass> I think we got the Errno one mapped out
<jhass> you can just Errno.new to raise the errno's
<jhass> raise Errno.new that is
<Kilo`byte> neat
<jhass> mmh, wasn't there some attempt at making them subclasses?
daneb has joined #crystal-lang
waj_ has joined #crystal-lang
<Kilo`byte> what the hell is wrong with my internet connection
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
<jhass> it's 2015 and it's not FTTH?
waj has quit [Ping timeout: 264 seconds]
waj_ is now known as waj
<daneb> Kilo`byte you not from south africa are you? ;)
<Kilo`byte> nah
<Kilo`byte> germany
<Kilo`byte> but i am stuck on wifi
<Kilo`byte> @[ReturnsTwice] - lol... you made an annotation for pretty much only a single function
<Kilo`byte> or w/e its called
asterite has quit [Quit: Page closed]
<crystal-gh> [crystal] asterite pushed 3 new commits to master: http://git.io/vtsf4
<crystal-gh> crystal/master 151af4c Ary Borenszweig: Fixed macro not found from virtual type
<crystal-gh> crystal/master 8117bb6 Ary Borenszweig: Added `-e` option to hierarchy command to filter types by a regular expression
<crystal-gh> crystal/master 3ae7581 Ary Borenszweig: Added `-v` as an alias of `--version`
<Kilo`byte> also, when i screw up with symbols in a lib block, how do i know from the error which one?
<jhass> Ctrl+F?
<Kilo`byte> the error message does not say
<Kilo`byte> i found it out though
<jhass> it says undefined reference, no?
<Kilo`byte> "$errno: Int32"
<Kilo`byte> is derping somehow
<Kilo`byte> FileDescriptorIO.o mismatches non-TLS reference in .../Process.o
<Kilo`byte> latter file is written by me
<jhass> uh
* jhass slowly backs off
<Kilo`byte> i think at least
<Kilo`byte> commenting out the $errno one fixes the error
<Kilo`byte> wait, $errno is already defined
<Kilo`byte> derp...
<jhass> ah, that should probably compiler error though
<jhass> redefining it that is
<Kilo`byte> jhass: also i should learn to read error messages. it started with /usr/bin/ld: errno:
<jhass> hehe
<jhass> well, if you ever did support you should know how hard people fail at reading :P
<jhass> we got a couple of error messages/safety checks saying "you didn't do X, do X"
<jhass> and they come "I get this message? what now?"
bcardiff has quit [Quit: Leaving.]
daneb has quit [Remote host closed the connection]
daneb has joined #crystal-lang
<Kilo`byte> jhass: does crystal have support for unix sockets yet?
<Kilo`byte> (the non-named kind)
waj has quit [Quit: waj]
<Kilo`byte> jhass: can't try in your playpen... for some reason it seems to not capture output by child processes
<jhass> link?
<Kilo`byte> it works locally
<vifino> Someone suggested a programming language should make errors/exceptions be called Spanish Inquisitions.
<vifino> I don't even.
<Kilo`byte> vifino: xD
<Kilo`byte> SpanishInquisition = Exception
<Kilo`byte> like that
<vifino> yeah, somewhat
<vifino> Riiight, back to learning to write LLVM IR by hand. Godspeed.
<Kilo`byte> good luck :P
<jhass> Kilo`byte: I didn't even know UNIXSocket.pair is a thing :D
<Kilo`byte> its great :P
<ozra> I thought I read here yesterday someone perhaps coding a ZMQ binding together?
<jhass> Kilo`byte: hm, I wonder if the fork fails to inherit stdout for some reason
<Kilo`byte> jhass: my intention is to spawn a root worker (through sudo) and both processes communicate via a socket
<Kilo`byte> probably
<Kilo`byte> is Process.run async? or rather, can i make it async
<Kilo`byte> or do i need to play with raw processes for that
<jhass> if you pass it IO-esque stuff for stdout/stdin it won't block
<Kilo`byte> meh... fork + exec + will do
<travis-ci> manastech/crystal#2555 (master - 3ae7581 : Ary Borenszweig): The build passed.
<Kilo`byte> jhass: this is complex. i need to wait until either sudo exists (user aborted) or i need to wait until the child process confirms its launch via the socket (user entered password)
<Kilo`byte> maybe i can trap a sigchld
<Kilo`byte> hmm
<Kilo`byte> yay... http://carc.in/#/r/57z
<vifino> ozra: Yeah, me, but I'm a crystal noob :D
<vifino> Noob as in, I've never written any projects with crystal :P
<ozra> vifino: Slightly OT, but what do you think of nanomsg? I haven't tried it yet.
<Kilo`byte> how'd i get the fd for an IO and also create a new IO from said fd
<vifino> ozra: nanomsg sounds cool, haven't looked at it too much.
<vifino> I'm still looking for a pubsub in which both client and server and sub and pub :)
<vifino> Probably gonna end up with MQTT.
<ozra> vifino: The notion of a 'better rewrite of ZMQ by a dev from ZMQ' does have a good ring to it ;-) Just don't know how mature it is.. Being in C probably makes it dead simple to jack into in with crystal.
<ozra> MQTT? I'm gonna google..
<vifino> ozra: Yeah, sounds neat :P
<vifino> All bindings/api's for MQTT suck though :v
<vifino> ( Yes, all suck. Every single one. )
<ozra> vifino: Wtf, that doesn't sound like a good future :-/ But I like that it is first citizen approaching bad bandwidth, shaky connections and energy consumption. That's the reality...
<vifino> ozra: It itself is glorious, but the interface to it are bleh... :/
<ozra> vifino: So whip up a binding for Crystal that kicks ass ;-)
<jhass> Kilo`byte: Signal::CHILD.trap
<Kilo`byte> oh nice
<vifino> ozra: Sounds like a plan :)
<ozra> :)
<jhass> Kilo`byte: and FileDescriptiorIO.new(io.fd) I guess
<jhass> or there's also dup somewhere
<vifino> ozra: Wanna do that together? :P
<Kilo`byte> yeah, i figured that out after 5 or so mins of reading documentation
<ozra> vifino: I think I'm a bit to tied up in other coding atm :-/ But I'd love to help out when/where I can! How horrible is the C++ API? (I will need to message rather large data to/from a C++ Qt UI App...)
<vifino> ozra: Didn't look at the C++ one yet :P
<vifino> But go google for eclipse paho
<ozra> vifino: So perhaps my use case is not the ultimate for the bad connection stuff (it will be used 99% on the same machine), but I mean, could use it anyway :)
<Kilo`byte> jhass: i kinda feel like i gotta work on the process api later
<Kilo`byte> adding some utilities
<Kilo`byte> like the ability to launch the process async, but to get a callback called when it exits
<vifino> ozra: You sadly need a server in the background, because it needs a router, but apart from that, it looks like it isn't too bad of a choice to use MQTT :)
<jhass> Kilo`byte: yeah sure
<jhass> Process.run also still doesn't has stderr mapped I think
<ozra> Aha, its brokered.. Hmm, that makes a difference in my case ofc :-/
<Kilo`byte> because if everone adds their own sigchld handler... that will get messy
<Kilo`byte> so better a central one
<jhass> https://github.com/manastech/crystal/pulls see the two oldest PRs
<jhass> Kilo`byte: oh btw http://carc.in/#/r/580 it's that the playpen kills everything if the parent exits
<Kilo`byte> oooo ic
shama has joined #crystal-lang
<Kilo`byte> jhass: Process.spawn(...) do {|event| ...}
<Kilo`byte> i kinda miss enums with values in crystal
<jhass> mh?
<Kilo`byte> (as known from most functional languages)
<Kilo`byte> enum Stuff
<Kilo`byte> Something
<Kilo`byte> SomethingElse(Int32)
<Kilo`byte> end
<Kilo`byte> latter enum value can contain an int32 when passed somewhere
<ozra> vifino: 's like - I've replaced dropbox with decentralized device syncing, torrent style, using syncthing - everythings moving away from centralized solutions ;-)
<jhass> mmh
<vifino> ozra: Nice :)
<Kilo`byte> you can work around that with classes, but its not as nice
<jhass> but then they're no longer singletons, right?
<Kilo`byte> class Stuff; end; class Something < Stuff; end; class SomethingElse; <forgot the helper function>; end
<ozra> vifino: well, I guess I might look at nanomsg anyway.. right now the old implementation I have just use http (because there was a web-interface parallell for a while).. so it's not step number one right now...
<Kilo`byte> jhass: i am not exactly sure how they are implemented, but you generally would use them like a = Stuff::SomethingElse(42)
<Kilo`byte> destructuring is another issue, you usually do that with pattern matching (maybe make the value behave like a tuple. that coule work)
<jhass> well, you could always write a macro to generate yourself some hierarchy of structs I guess :P
<Kilo`byte> i may actually play with that stuff
<Kilo`byte> not now though
<Kilo`byte> i'll actually take a break
<Kilo`byte> tbh, i just learned about crystal yesterday and its already my favourite language
<Kilo`byte> xD
bcardiff has joined #crystal-lang
<jhass> yeah it does that xD
<Kilo`byte> or was it tuesday, i forgot
<vifino> I forgot to ask; Is there documentation for `asm` yet? :P
<Kilo`byte> syntax wise i like scala even more, but that compiles to java bytecode which makes it really bloaty
<ozra> Kilo`byte: Learned yesterday too, and I get happily surprised all the time, have my gripes, but they're minor compared to the good stuff :)
<Kilo`byte> i mean, i have been working with ruby for quite some time now
<Kilo`byte> makes understanding crystal much easier
<jhass> I have to agree with asterite though that we're at a point where we should be careful with adding/changing syntax/language features too much
<jhass> there are a lot of people discovering it with diverse backgrounds and having all kind of ideas from everywhere
<jhass> trying to add them all now wouldn't be wise
<jhass> we should rather build a community, discover patterns & anti patterns of the language and see where the majorities are/where useful changes are
<Kilo`byte> yeah
<Kilo`byte> you can always add on later
<Kilo`byte> removing is way harder
<jhass> that is real pain points, not much "it would be nice to have" stuff
<ozra> jhass: Yes, we are many ;) But I think that's good - there are great parts that would fit from functional territory and others too - the right parts should find a place when consensus is reached.
<Kilo`byte> yes
<jhass> I still think I'd like to see 1.0 without all that though, maybe for 2.0
<jhass> but 1.0 should get what we have so far rock solid first
<Kilo`byte> syntax wise the lang should be mostly ready for 1.0 - just stdlib and stability stuff i'd say
<ozra> I think it would be important to shake out some things _before_ 1.0, because at that point their cut in stone..
<Kilo`byte> although i don't know it very well yet
<jhass> ozra: ruby 3.0 thinks about adding soft/gradual typing, I'm not sure how much in stone stuff really is ;)
<ozra> Well, if old code is supposed to be compilable..
<jhass> I'm not saying to not change stuff if we discover anti patterns before 1.0
asterite has joined #crystal-lang
<ozra> I mean things like the issue of `id?()` vs `?` for other uses, etc. I'm still too new to have formed opinions about it - I'm still building my minimum case of POC that worked out greatly, now I'm building upon it trying things that may introduce problems and/or teach me more :-)
<jhass> there's just enough in the stuff that exists already that needs to be worked out, if we keep adding stuff we never reach a stable language
<asterite> vifino: asm has pretty much the same syntax as in rust, so: https://doc.rust-lang.org/book/inline-assembly.html
<Kilo`byte> jhass: i actually really like the Type1 | Type2 stuff
<Kilo`byte> makes polimorphic code really easy, even if you manually specify types
<asterite> so we thought there was no need to reinvent the wheel
<willl> yeah the union types make the crystal type system so much less a pain in the ass compared to go
<vifino> asterite: Hey there, and thanks :)
<asterite> willl: really? I thought interfaces were pretty good for that in go
<Kilo`byte> if you have 3 wrappers for the same function with just different types and the wrapped function also has 3 versions, i only need one wrapper
<Kilo`byte> as long as the arg count matches
<asterite> willl: or, said another way, I'd like to know what are the pains in go (so we can improve that, of course)
<willl> asterite: take a look at https://github.com/heroku/pgdiagnose
<willl> it's super simple, run a few sql commands on a database, but because each query needs a different type, trying to put them all together, you have to resort to interface{}
<willl> then at that point there is no point to the type system
<vifino> asterite: What about inline llvm ir? Wouldn't that be better suited? At least you don't have to worry about your target! :D
<willl> I tried to get them all to have a similar interface to work, but there were other complications, but it's been long enough I forgot exactly why it wouldn't work that way unfortunately.
<asterite> vifino: crystal code is pretty much inline llvm, most of the time it's a 1 to 1 translation
bcardiff1 has joined #crystal-lang
<asterite> willl: I see. Yes, interface{} is the main complaint in go, I think
<vifino> asterite: Sorry, didn't understand that one - I meant something like `asm` but for llvm ir, is that what you mean, or not? o.O
bcardiff has quit [Ping timeout: 264 seconds]
<asterite> vifino: the problem with that is that we tie ourself to a particular backend... maybe if one day we want to switch to gcc, we can't. But asm is down there everywhere
<vifino> Hmm...
<vifino> An undocumented unsupported function for that would be awesome anyhow xD
bcardiff has joined #crystal-lang
<asterite> Also, if you check llvm's reference ( http://llvm.org/docs/LangRef.html ) we cover almost every instruction. For example 1 + 2 is the add instruction, etc.
<vifino> Alright :)
bcardiff1 has quit [Ping timeout: 265 seconds]
<asterite> I still need to add it to the docs, as well as other minor things
asterite has quit [Ping timeout: 246 seconds]
<ozra> What notation / whatnot is available for handling mutability vs immutability for vars and arguments in crystal?
BlaXpirit has quit [Quit: Quit Konversation]
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
shama has quit [Quit: (╯°□°)╯︵ɐɯɐɥs]
bcardiff has quit [Quit: Leaving.]
datanoise has quit [Ping timeout: 265 seconds]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
datanoise has joined #crystal-lang
NeverDie has joined #crystal-lang