ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's 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
<FromGitter> <carsonbaker> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=591b95a7f3001cd3422b9ba6]
<FromGitter> <carsonbaker> Error in hmm.cr:10: can't take address of wuu.fee
<FromGitter> <carsonbaker> Why is this?
zipR4ND has quit [Ping timeout: 268 seconds]
<FromGitter> <carsonbaker> Oh, I think I see. It's because fee isn't a variable in that context. It's an accessor.
<FromGitter> <carsonbaker> I can do ```pointerof(wuu.@fee)``` and it works. Problem solved!
<FromGitter> <Sija> better save to a local variable instead
<FromGitter> <Sija> `object.@variable` syntax is kinda unofficial
<FromGitter> <Sija> used mainly in specs
<FromGitter> <carsonbaker> @sija, sorry, what do you mean save to a local variable?
<FromGitter> <Sija> like `fee = wuu.fee`
<FromGitter> <carsonbaker> So I'm writing some C bindings where a function takes Bar.fee by reference.
<FromGitter> <carsonbaker> I guess I could do ```tmp = wuu.fee; LibWhatever.set_the_thing(pointerof(tmp)); wuu.fee = tmp;``` but that's awkward.
<FromGitter> <Sija> why do use need to pass `wuu.fee` in the first place?
<FromGitter> <carsonbaker> The library is LibSRTP. <https://github.com/cisco/libsrtp/blob/master/include/srtp.h> The function in this context is line 707 srtp_crypto_policy_set_rtp_default.
<FromGitter> <carsonbaker> It takes a pointer to a ```srtp_crypto_policy_t``` which is held inside a struct of type ```srtp_policy_t```
<FromGitter> <carsonbaker> I'm sorta just following the example code they have in the repository readme.
<FromGitter> <Sija> nested structures, uhm
<FromGitter> <Sija> i’d go with `obj.@var` notation than and w8 for better advise/times ;)
<FromGitter> <Sija> btw, there’s also https://github.com/crystal-lang/crystal/issues/3073 which might interest u
<FromGitter> <carsonbaker> Oh, interesting. This is why Larry Wall took 18 years to design Perl 6.
<FromGitter> <Sija> lol
<FromGitter> <Sija> Crystal trip allows me to learn a lot about compiler intricaces, that’s for sure ;)
sagax has quit [Ping timeout: 240 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<crystal-gh> [crystal] at-grandpa opened pull request #4421: Fix benchmark.cr documentation. (master...fix/benchmark_doc) https://git.io/v9AzP
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest75330
Guest75330 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mark_66 has joined #crystal-lang
bjz has joined #crystal-lang
bjz has quit [Client Quit]
bjz has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
<FromGitter> <pawandubey> So I am very excited about Crystal as a 5 minute translation of my Ruby gem to a Shard resulted in a 20X performance boost. But I am still not sure about the idioms of how shards are supposed to be distributed. I know the shard.yml workflow but do we just distribute the source? What if I have a crystal binary that I want to link to in my app, how do I go about doing that?
sz0 has quit [Quit: Connection closed for inactivity]
<crystal-gh> [crystal] akzhan opened pull request #4422: Add .editorconfig template on crystal init command. (master...add-editorconfig-on-crystal-init) https://git.io/v9xkS
Kug3lis has joined #crystal-lang
Kug3lis has quit [Client Quit]
zipR4ND has joined #crystal-lang
Kug3lis has joined #crystal-lang
<FromGitter> <andreaTP> crystal compile everything from sources, you produce a binary only if it is a "end user" application
<FromGitter> <andreaTP> otherwise for libraries you provide your sources
zipR4ND has quit [Ping timeout: 272 seconds]
bjz has quit [Ping timeout: 246 seconds]
bjz has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <KCreate> @pawandubey You could try emitting a crystal binary as an object file and trying to link that.
<FromGitter> <KCreate> But I never tried that so I don't know if it works
Kug3lis has joined #crystal-lang
<FromGitter> <schoening> Wow... srsly f**k Windows. It has been updating for so long im not getting any work done. On the bright side i had plenty of time in the massage chair today
<FromGitter> <aolko> :/
livcd has quit [Changing host]
livcd has joined #crystal-lang
<FromGitter> <schoening> After it updated it showed the login screen. Waiting for me to click a button so it could say "Hi" and keep updating haha.. ⏎ Linux is so much better in so many ways it's not even funny xD Oh well /rant
<FromGitter> <bew> @KCreate compiling object files from crystal source, then linking to a project works (ysbaddaden did an experiment here: https://github.com/ysbaddaden/crystal_library)
<FromGitter> <KCreate> @schoening Are you also a member of the ForcedToWorkWithWindows club?
<FromGitter> <schoening> I am. I'm the newly hired front end guy in a crowd of c# devs :smile:
<FromGitter> <bew> front end? and you're forced on windows for this, or is it personal choice?
<FromGitter> <schoening> Forced. My stack for hobby stuff is Gulp, browserify etc. But I am forced to switch to Visual Studio and windows.. It has some niceties but holy cow I also feel slow at times.
<FromGitter> <schoening> The guys I am working with are awesome tho. I enjoy this place a lot
<FromGitter> <aolko> > ut I am forced to switch to Visual Studio ⏎ ⏎ ouch
<FromGitter> <schoening> The debugging tools of visual studio are pretty damn nice..
<FromGitter> <schoening> But I have been using sublime for so long.. its hard to get used to this
<FromGitter> <aolko> i prefer jetbrains' products
<FromGitter> <aolko> and sublime is just yet another notepad++ replacement
<FromGitter> <schoening> There, there. Let's not get too carried away with that religious debate :p
<FromGitter> <aolko> it's actually kinda true
<FromGitter> <schoening> If we can get crystal to 1.0 with windows support perhaps I can convince the boss to rewrite something small in it :D would be sweet
<FromGitter> <aolko> that should've been :top:
bjz_ has joined #crystal-lang
<RX14> that reminds me to attempt to get the compiler to produce empty windows executables
bjz has quit [Ping timeout: 240 seconds]
<FromGitter> <aolko> actually there's some progress https://github.com/crystal-lang/crystal/pull/3582
<RX14> yes there's a lot of progress on the stdlib
<RX14> however the compiler hasn't had the appropriate modifications yet
<RX14> (they use a workaround by dumping llvm bitcode)
<FromGitter> <bew> what kind of modifications would be needed?
<RX14> i'm not sure but I hope I can work it out
<FromGitter> <aolko> > a lot of progress ⏎ > list haven't been updated
Kug3lis has quit [Read error: Connection reset by peer]
Kug3lis has joined #crystal-lang
<FromGitter> <schoening> @KCreate super cool you wrote a programming language btw.
<FromGitter> <KCreate> @schoening lol thanks!
<FromGitter> <KCreate> The code is super messy and it's horribly inefficiently written, but maybe I'll write a better version at some later point
<FromGitter> <schoening> It's a massive feat tho. I'm gonna go look through it a bit. Always wanted to write a language. How did you get started?
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kug3lis has joined #crystal-lang
<FromGitter> <l3kn> @schoening If you are looking for something small to start with, https://github.com/kanaka/mal/blob/master/process/guide.md might be interesting
<FromGitter> <aolko> hmm, there's make-a-lisp, but not make-a-basic, paradox
<FromGitter> <bew> yeaah mal, I have this tab opened since 2-3 months to remind me ^^
Raimondii has joined #crystal-lang
<FromGitter> <KCreate> @schoening Reading crystal's lexer and parser source code helped a ton.
<FromGitter> <KCreate> The whole syntax part was the most difficult imho, executing the resulting AST is kind of straigh-forward
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <l3kn> Building a compiler is pretty interesting, too. I found http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf to be a good introduction to that topic
<crystal-gh> [crystal] akzhan opened pull request #4424: Fixes #4361 wrong error message: unexpected token: end (master...fix-4361-unexpected-token-end-expecting-when-else-or-end) https://git.io/v9x0W
<FromGitter> <aolko> still lisp
<FromGitter> <l3kn> The way different types are encoded should be applicable to all kinds of languages, I think lisp is popular for these kinds of introductions because parsing it is so easy
<FromGitter> <KCreate> @l3kn How detailled does that article get?
<FromGitter> <schoening> @l3kn , @KCreate thanks! :D
<FromGitter> <l3kn> @KCreate Not that much, but it gives a rough idea how one would represent different data types (using 3 bits to store a type tag)
<FromGitter> <KCreate> @schoening Might also check out this repository on github (https://github.com/aalhour/awesome-compilers) which is trending since a couple of days
<FromGitter> <l3kn> After a while, juggling around registers gets pretty painful
<FromGitter> <KCreate> @l3kn Is your `lisp-compiler-llvm` repo based on that article?
<FromGitter> <l3kn> @KCreate Yes, I started with https://github.com/l3kn/lisp-compiler but moved to LLVM-IR because it was easier to work with
<FromGitter> <KCreate> Cool, I'll definitely add that to my read-later list :)
<FromGitter> <schoening> I want to print this and put it on the wall at the company https://assets.toggl.com/images/toggl-how-to-save-the-princess-in-8-programming-languages.jpg
<FromGitter> <schoening> What would a crystal panel on that comic say you think? :D
<FromGitter> <aolko> "my language is better, y'all suck"
<RX14> it probably wouldn't be noteworthy enough to make a joke about, or maybe a pun on one of the language features
<FromGitter> <aolko> Crystal is just a giant gem, gems can't save princesses ;)
<FromGitter> <schoening> I dunno. I use js and can laugh about the flaws :D
<crystal-gh> [crystal] akzhan closed pull request #4424: Fixes #4361 wrong error message: unexpected token: end (master...fix-4361-unexpected-token-end-expecting-when-else-or-end) https://git.io/v9x0W
<crystal-gh> [crystal] akzhan reopened pull request #4424: Fixes #4361 wrong error message: unexpected token: end (master...fix-4361-unexpected-token-end-expecting-when-else-or-end) https://git.io/v9x0W
<crystal-gh> [crystal] akzhan closed pull request #4420: More documentation for Exception class. (master...doc-Exception-class-more) https://git.io/v9AG6
sz0 has joined #crystal-lang
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vasilakisfil has joined #crystal-lang
<vasilakisfil> hey people is there anything in Crystal like Rack in Ruby ? (or Plug in Elixir)
<FromGitter> <Sija> i don’t think so, though I’d like to take a stab at it
<FromGitter> <straight-shoota> Crystal has HTTP::Server and HTTP::Handler wich is a different concept, but the handlers are somewhat similar to Rack middleware.
<crystal-gh> [crystal] akzhan reopened pull request #4420: More documentation for Exception class. (master...doc-Exception-class-more) https://git.io/v9AG6
<vasilakisfil> ok
mark_66 has quit [Remote host closed the connection]
vasilakisfil has quit [Quit: Konversation terminated!]
unshadow has joined #crystal-lang
sagax has joined #crystal-lang
unshadow has quit [Quit: leaving]
pwned has joined #crystal-lang
<pwned> hi I'm a ruby apostate
<FromGitter> <bew> Hi we're crystal apostate :)
<FromGitter> <bew> oops mis-understood the word I think...
<pwned> it means I renounced ruby and have to be punsished with various exotic languages
<FromGitter> <bew> @pwned why?
<pwned> it's slow
<pwned> I coded ruby for 6 years
<pwned> it's gotten pretty good though.
<pwned> I wanted to wrap an iterator returned from @iter = File.each_line so I can do def next; line = @iter.next; # do stuff with line, but crystal says IO::LineIterator is private so I'm stuck
<pwned> I'm back to noob 101
<crystal-gh> [crystal] mverzilli pushed 1 new commit to master: https://git.io/v9pTW
<crystal-gh> crystal/master fe78661 Akzhan Abdulin: Fixes #4361 wrong error message: unexpected token: end...
<RX14> pwned, try just using iterator as the type of the variable
<RX14> if IO::LineIterator is private
<FromGitter> <bew> you mean `Iterator` I think
<RX14> yeah
<FromGitter> <straight-shoota> @pwned there are a few quirks you have to know, but I find it generally very easy to transfer from ruby to crystal.
<FromGitter> <johnjansen> unless you use alot of meta programming
<FromGitter> <straight-shoota> yeah, but once you are comfortable with macros, it's not that much of a loss.
<FromGitter> <johnjansen> loss, NO … always easy, also NO ;-)
<FromGitter> <johnjansen> worth the time, YES YES YES
<pwned> OK that's great it worked up to a point
<pwned> thanks for that
<pwned> but if next's return type is Iterator::Stop | String how can I pass to a function that does split and stuff
<pwned> it says split not defined for Iterator::Stop
<pwned> ooh
<pwned> I have an idea. I will overload a function for both Stop and String
<FromGitter> <bararchy> or just cast the return to `.as(String)`
<FromGitter> <johnjansen> probably not the ideal solution
<FromGitter> <bararchy> You can also ⏎ ⏎ ```if value.is_a?(String) ⏎ bla bla ⏎ else ⏎ blab la ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=591c951f0a783b6c0aaae6d5]
<FromGitter> <johnjansen> `Iterator::Stop` has a meaning, personally, id interpret that meaning and handle it accordingly. implicitly ignoring it seems to miss the point
<RX14> pwned, you have to detect if the result is an Iterator::Stop and if it is handle that case
<RX14> it'll be Iterator::Stop when the iterator has finished
<FromGitter> <johnjansen> ;-) @RX14
<RX14> pwned, what exactly are you trying to do? Could it be done with Iterator#map?
TheLemonMan has joined #crystal-lang
<pwned> RX14: I'm trying to read from a csv and use it in a transaction, so I need to read it part by part (like 1000 line at a time) using each_slice(1000) otherwise I run out of memory
<pwned> I made something like this https://play.crystal-lang.org/#/r/21ab it seems to work
<pwned> I guess 23:25 is unnecessary
<oprypin> maan, it really hurts to see these manually written iterators
<pwned> I should write something that automates writing iterators?
<oprypin> not you
<oprypin> pwned, btw why do you need the iterator, couldn't you just write file.each_line.each_slice(10)
<oprypin> c# has something that automates writing iterators
<pwned> ruby has enum_for
<oprypin> you just write one function with a loop and yield, and everything is figured out
<oprypin> well any decent interpreted language has that but yeh
<pwned> I guess I wanted to learn. I have no excuse for not using gile.each_line.each_slice
<oprypin> ok
<pwned> I could just parse the stuff inside there
<RX14> pwned, you can look at existing wrapper iterators to get an idea if you want
<TheGillies> what's going to the hawtness in next cut of crystal?
<RX14> not much yet as far as I can see
zipR4ND has joined #crystal-lang
<RX14> i uhh think I found a coverage tool that works on crystal
<RX14> i've been looking for so long...
<FromGitter> <johnjansen> seriously
<FromGitter> <johnjansen> thats a huge find
<FromGitter> <fridgerator> wuuuut
<RX14> not very hard but I just looked up what rust did lol
<RX14> and they use a tool called kcov
<RX14> and it works on any executable
<RX14> no compiler changes required
<FromGitter> <johnjansen> great
<RX14> and i've tried it out on the compiler specs
<RX14> and it works... somewhat
<FromGitter> <johnjansen> whats the output like ooi
<FromGitter> <johnjansen> im assuming its the usual format (but want a sample ;-)
<RX14> here's a screenshot: https://aww.moe/krqnho.png
<RX14> it can output cobertura XMLs and pretty much everything
<FromGitter> <fridgerator> thats crazy
<FromGitter> <fridgerator> and awesome
<RX14> there's lots of code not highligted at all
<FromGitter> <johnjansen> yeah … cant believe you didn’t test that `size == 0` ;-)
<RX14> which I assume is code that's not compiled in
<FromGitter> <fridgerator> lol
<FromGitter> <johnjansen> ;-)
<FromGitter> <ltran> im using spawn and inside that make a webreq and then print some value, ⏎ the `puts` are getting mingled up and repeats. =) anyone have ideas around this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=591cb48700efc2bb3e7a2271]
<Papierkorb> ltran, please post code.
<FromGitter> <ltran> sure. 1 sec
<FromGitter> <drujensen> @RX14 That is one heck of a find. `crystal coverage`
<RX14> well we don't need a crystal coverage now
<RX14> we can just point people to kcov
<RX14> "that works out of the box"
<FromGitter> <drujensen> right.
<FromGitter> <johnjansen> @RX14 have you time to put together a quick “how to”
<FromGitter> <johnjansen> this will help when someone asks, rather than us bumbling around looking …
<FromGitter> <drujensen> @sdogruyol When you do the weekly mailer, maybe link to `kcov`?
<FromGitter> <l3kn> mon
<RX14> 1) install kcov 2) compile your spec suite using `crystal build spec/foo_spec.cr` 3) kcov out-dir --verify ./foo_spec
<FromGitter> <johnjansen> alright then ;-)
<FromGitter> <ltran> damn tag people in irc? @papierkorb https://gist.github.com/ltran/3ca61dde2f932b495bf3f570b7460d81
<RX14> unfortunately there's no current way to create an executable of your specs easily
<RX14> a good work item would be an option to crystal spec to dump an executable
<RX14> which you can then use kcov on
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<RX14> because currently you'd have to create an `all_spec.cr` file which contained `require "./**"`
<FromGitter> <drujensen> does kcov have a c library?
<FromGitter> <johnjansen> i think you need a single fiber doing all the `PUTS` but i could be wrong.
<Papierkorb> you can puts all you want
<FromGitter> <johnjansen> @ltran i cant see any repeats
<RX14> wow
<RX14> all_spec has an 88.3% coverage
<FromGitter> <johnjansen> thats impressive
<FromGitter> <g33kidd> I'm about to start a project using Crystal. Has anybody created or found a Stripe lib for payments?
<FromGitter> <g33kidd> Couldn't find one on awesome-crystal :frowning:
<FromGitter> <bew> don't think there is one ATM... did you checked on http://crystalshards.xyz/ ?
<FromGitter> <straight-shoota> http://crystalshards.xyz/?filter=stripe
<FromGitter> <ltran> @johnjansen hey thanks for looking into it, i recorded my output and can be replayed at http://showterm.io/8c11c66ae13f108c7fe25 if you scroll the bottom bar to roughly the middle you can see the prints getting put onto the same line.
<FromGitter> <g33kidd> I forgot about this site, thanks!
<FromGitter> <johnjansen> @ltran i have seen something like that before, wouldnt want to speculate about why, i would try creating a fiber to do all the puts and use a channel to communicate with it … just see if that helps understand the problem
<FromGitter> <ltran> @johnjansen ah okay, ya that was my next approach, making sure i wasnt missing somethingn obvious or something ;D
<FromGitter> <johnjansen> like i say, i personally wouldnt speculate why. although im guessing that puts is not acting atomically (which would be blocking i assume)
bjz has joined #crystal-lang
<oprypin> i think it would be a pretty cool feature to make `puts` calls block stdout
<FromGitter> <bew> @oprypin block stdout? like mutex locks?
<FromGitter> <johnjansen> thats sounds decidely uncool
<FromGitter> <straight-shoota> Maybe use `print` instead of `puts`? This would eliminate the check if the string ends with `'\n' `... Maybe that might reduce the risk of concurrency issues.
<FromGitter> <bew> using print over puts won't resolve it, the `\n` check does not block the current fiber, and doesn't have concurrency issues
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
dom96 has quit [Changing host]
dom96 has joined #crystal-lang
zipR4ND has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> weird: https://carc.in/#/r/21bi
<FromGitter> <bew> the initialize of parents of parent class cannot be accessed via `super`
sz0 has quit [Quit: Connection closed for inactivity]
zipR4ND has joined #crystal-lang
pwned has quit [Ping timeout: 255 seconds]