ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | 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> <elorest> <BlaXpirit> @fridgerator lenticular printing currently only seems to support 10 frames so this is what I have so far. Will probably work on it a bit more. http://giphy.com/gifs/crystal-lang-logo-l1BgSYVQGMWjATwwo
<FromGitter> <Sija> @Zhomart https://github.com/schovi/baked_file_system
<FromGitter> <Sija> regarding “baking” in files inside the exec
<FromGitter> <will> I have part some json that is array pairs of floats. Is there any easy way to parse that into a NamedTuple or Tuple? Right now I'm using my own struct with an initializer that uses the pull parser, but curious if there is a simpler way
<FromGitter> <elorest> @will maybe not as performant but it might be simpler to use an array or hash.
<FromGitter> <Sija> passing `{Float64, Float64}` as `type` argument works for me
<FromGitter> <elorest> <BlaXpirit> @fridgerator lenticular printing currently only seems to support 10 frames so this is what I have so far. Will probably work on it a bit more. https://isaacsloan.com/crystal-fast.gif ⏎ Gif might be useful for a talk at crystal code camp too so here it is.
<FromGitter> <Sija> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d7143bc4ac989f3cb703b5]
<FromGitter> <will> oh interesting. I hadn't actually tried just a Tuple, only NamedTuple, which doesn’t work
<FromGitter> <will> but just creating an alias for Tuple(Flaot64, Float64), then using that works perfectly
<FromGitter> <will> thanks!
<FromGitter> <Sija> oh, my bad
<FromGitter> <Sija> yw!
<FromGitter> <Zhomart> @Sija omg thank you! I've already started implementing my spagetty code.. I'll use it.
<FromGitter> <bew> also: `Array({Float64, Float64}).from_json("[[1, 2], [3, 4.2]]")` gives: `[{1.0, 2.0}, {3.0, 4.2}]`
stnly has quit [Ping timeout: 260 seconds]
DaleK5whr has joined #crystal-lang
stnly has joined #crystal-lang
DaleK5whr has quit [Quit: Leaving]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
carbonage has quit [Read error: Connection reset by peer]
carbonage has joined #crystal-lang
stnly has quit [Quit: leaving]
stnly has joined #crystal-lang
<FromGitter> <faustinoaq> ```class Foo ⏎ class_property bar = 0 ⏎ end ⏎ Foo.bar # => 0``` [https://gitter.im/crystal-lang/crystal?at=58d745614cb8d0917328d5ec]
<FromGitter> <faustinoaq> which is better?
<FromGitter> <faustinoaq> I have seen the first one in many shards
_whitelogger has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 240 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
_whitelogger has joined #crystal-lang
vegai_ has joined #crystal-lang
unshadow has joined #crystal-lang
Qchmqs has joined #crystal-lang
jfontan has quit [Ping timeout: 240 seconds]
bungoman has joined #crystal-lang
<FromGitter> <Sija> @faustinoaq I’d go for 1st option since it allows you to override `INSTANCE` property if needed and scopes data to given object instead of class
jfontan has joined #crystal-lang
<FromGitter> <KCreate> Didn't know class_property existed
<BlaXpirit> KCreate, it's new
<FromGitter> <Sija> quite new, it has been added in v0.20.3
foxxx0 has quit [Quit: WeeChat 1.7]
n0r1x has joined #crystal-lang
<n0r1x> Hello :) Question: is it normal that my version of Crystal can't find the "crc32" library?
<BlaXpirit> n0r1x, kinda normal, if you have an old version of crystal
<FromGitter> <bew> What version do you have?
<n0r1x> I'm using the one from the arch repos, that might be the problem
<BlaXpirit> added in version 0.21 - check yours with `crystal -v`
<n0r1x> crystal -v Crystal 0.20.5 (2017-01-25)
<BlaXpirit> n0r1x, oh yeah, arch currently has the biggest delay that i've ever seen
<n0r1x> yup, thanks :)
<n0r1x> Do you mean that nobody is updating the official repos? I don't use my arch that much and installed it as a hobby system so I'm not really on top of the news
<BlaXpirit> n0r1x, can use https://aur.archlinux.org/packages/crystal-git/ or to more easily follow the development (aur package redownloads and runs all unittests, bleh), download and compile manually, it's easy
<BlaXpirit> n0r1x, well yeah, someone close to arch development decided to take up this package that used to be maintained by users, and now they're not updating it for whatever reason
<n0r1x> yeah, I have pacaur since I had to install android studio, I'm gonna pacman -R it and packaur -S that one
<n0r1x> I've noticed a tendency from the arch contributors to take "in" programming languages into the pacman repos and leave all the tools you'd want to use with them into the AUR
<n0r1x> ok strange, my pacman auto quits out of the y/n prompts
<BlaXpirit> n0r1x, ayyup that's actually a bug caused by crystal, believe it or not
<BlaXpirit> something that crystal does affects the terminal session consequently
<BlaXpirit> you can restart your terminal window/whatever
<n0r1x> It's trying to block its certain removal
<BlaXpirit> :>
<n0r1x> It's becoming conscious :O
<unshadow> n0r1x: Arch user here, jhass is mainatinig the crystal-git version in the AUR and it's almost allways one or two days from release to package update, you can also pinghim anytime XD
<BlaXpirit> unshadow, because it's a -git package, you can just reinstall it anytime without any need to update it in aur
<unshadow> BlaXpirit: It's not realy a git package, jhass is following with compile from git to a certain tag where the tag is the version , you can see it in the PKGBUILD, also here: https://aur.archlinux.org/packages/crystal-git/ where it was discussed
<BlaXpirit> unshadow, no, i'm pretty sure it installs latest commit
<unshadow> pkgname=crystal-git
<unshadow> pkgver=0.21.1.r2.g5b32e46bc
<unshadow> _last_release="0.21.1-1"
<unshadow> source_x86_64+=("https://github.com/crystal-lang/crystal/releases/download/${_last_release/-*/}/${pkgname/-git/}-$_last_release-linux-x86_64.tar.gz")
<BlaXpirit> no need to copypaste this here, easier to just install it and then check the version
<n0r1x> It's compiling right now
<unshadow> I think this clearly show it's "hardcoded" to 0.21.1-1
<n0r1x> Was making a silly tool that (hopefully) prints out an image to terminal via ansi character codes
bungoman has quit [Quit: Leaving]
<BlaXpirit> welp crystal-git is compiling way too long, that is not normal
n0r1x has quit [Ping timeout: 260 seconds]
<BlaXpirit> it is in fact broken
<unshadow> :\ I'll try to build too
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
n0r1x has joined #crystal-lang
<n0r1x> ok, pacaur crystal git didnt work i guess
<unshadow> n0r1x: It seems that yaourt is handeling it better :)
<n0r1x> really?
<n0r1x> Hmm, I don't like installing too many managers
<n0r1x> but where would the difference between the two lie?
<n0r1x> Because I figured that it took so long because it had to swap with the hard drive
<n0r1x> (and then crashed)
<RX14> n0r1x, just downloading the linux distribution is probably your best bet
<RX14> that or using crenv to downloadint for you
<unshadow> n0r1x: How much RAM do you have ? also, how much space you got in /tmp/ ?
<RX14> hopefully crane, the version manager i'm working on, will be finished soon...
<n0r1x> 6 gigs in ram
<BlaXpirit> unshadow, i have a ton of ram and it didnt do anything in 30 minutes
<RX14> yeah compiling with LLVM 3.5 is broken in release mode
<RX14> upgrading to llvm 3.8+ fixes it
<BlaXpirit> except it's 3.9.1
<unshadow> BlaXpirit: just n0r1x said the machine was swapping, so ...
<RX14> BlaXpirit, except the bundled version of llvm with crystal is 3.5 still
<RX14> and if you download the linux package from the github releases it uses llvm 3.5
<RX14> which sucks
<n0r1x> I think it was swapping since the computer basically got stuck, i was playing a youtube video (song) in the background and it kept stopping and starting
<n0r1x> and my mouse didnt work
<RX14> yeah
<RX14> you need 8gb ram minimum for a release compiler
<BlaXpirit> i have 16 and it doesnt compile
<RX14> but you're not running out of memory BlaXpirit
<BlaXpirit> no, it's just stuck for very long
<RX14> you're hitting the llvm 3.5 release bug
<RX14> which hangs release builds forever
<BlaXpirit> anyway... n0r1x, i have to suggest compiling from source yourself
<BlaXpirit> you have crystal from repos installed which should be good but also download source from github and run make
<RX14> you'll probably have to build a debug compiler if you only have 6gb ram
<n0r1x> debug compiler?
<RX14> meaning non-release build
<RX14> that's all
<n0r1x> aka just git pull and install it manually?
<RX14> yes
<BlaXpirit> n0r1x, do not *install* it, use it from the directory
<RX14> n0r1x, in the crystal repo there's a file called bin/crystal which you can use from anywhere
<RX14> you can probably symlink it from /usr/local/bin/ if you want
<n0r1x> ok
<n0r1x> huh, so I need to have crystall installed to run it ...
<n0r1x> so my best bet is reinstalling the pacman version
<n0r1x> compiling the debug version
<n0r1x> and 'swapping out' the pacman exec with the debug one?
<BlaXpirit> n0r1x, pls no
<n0r1x> *to run make
<BlaXpirit> indeed, install the one from pacman, download crystal source code and run make there, that's it
<n0r1x> Took about 10 secs to compile this time
<n0r1x> running the spec
<n0r1x> Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues
<RX14> what's the message?
<RX14> you ran `make spec` and it said that?
<n0r1x> ran make
<n0r1x> it finished with no particular message
<RX14> yup
<n0r1x> than i ran make spec
<RX14> and what does it say in addition to that
A124 has joined #crystal-lang
<RX14> there will be an error message
<n0r1x> and then it printed this: http://pastebin.com/0CNagyFm
<RX14> oh, yeah
<RX14> `make spec` really fucks with the ram
<unshadow> fork: Cannot allocate memory
<RX14> it basically compiles the whole compiler, the whole stdlib, and their specs
<RX14> and that's a huge executable which takes loads of ram the compile
<n0r1x> ok
<n0r1x> so I just gotta hope that it's gonna work I guess :p
<RX14> took 5.2gb of ram on my PC
<RX14> n0r1x, we use CI so it's very likely to work
<n0r1x> uninstalled the pacman one, symlinked it and crystal -h works
<FromGitter> <bjeanes> is there a valid way to represent this pseudo-code: `class Hash(K, Array(K)) forall K`?
A124 has quit [Quit: '']
<RX14> no, you can't restrict generics right now in crystal
jfontan has quit [Ping timeout: 240 seconds]
<RX14> what you can do however is use macros to check the generic args
<n0r1x> Is there a way to find out what type a function returns? The compiler finally got past the 'crc32' thing, but now it's asking me to infer the type of a class member
<RX14> you can execute puts typeof(thing)
<BlaXpirit> n0r1x, typeof(some_function(asdf))
A124 has joined #crystal-lang
<FromGitter> <bjeanes> @RX14 no worries, it's not a big deal at the moment. It'd just be nice to make an invalid piece of data unrepresentable here. tl;dr using a Hash(K, Array(K)) as a DAG for tsort-ing. Hash(K, V) where V != Array(K) is incoherent
<RX14> yeah
A124 has quit [Quit: '']
<FromGitter> <bjeanes> @RX14 you said "right now". Is this something that is otherwise planned/discussed?
<RX14> maybe...
A124 has joined #crystal-lang
<RX14> i don't know
<RX14> i could see it being implemented
<FromGitter> <bjeanes> It's one of the very nice parts about Rust's traits+generics interaction IMO
<FromGitter> <bjeanes> The implications could be surprising to some but welcome to others. For example, methods being defined on Foo(T) but not on Foo(V)
<FromGitter> <dreyks> this can actually be done as a shard using the same macros technic
<RX14> i'd be +1 for it being implemented given a nice syntax and semantics
<RX14> and i can'
<RX14> t think why ary would be against it
jfontan has joined #crystal-lang
<FromGitter> <bjeanes> @RX14 is there an issue tracking anything adjacent to this? If not, do you think I should open one with my use case as context? Admittedly, it wouldn't happen till tomorrow anyway as it's almost midnight here so I need to sleep soon
<RX14> yeah, open an isue if there isn't already one
<unshadow> Did you guys saw this: https://github.com/costajob/app-servers#results ? really cool (was added to the main site)
<RX14> yeah, I love crystal's IO model
<RX14> scheduler using libevent + super leightweight fibers
<unshadow> Interesting what would be achived when full Parralisem will be supported
n0r1x has quit [Ping timeout: 260 seconds]
n0r1x has joined #crystal-lang
<crystal-gh> [crystal] MakeNowJust opened pull request #4196: Refactor Colorize#surround (master...fix/colorize/refactor-surround) https://git.io/vSIHt
bjz_ has quit [Ping timeout: 240 seconds]
bjz has joined #crystal-lang
A124 has quit [Quit: '']
A124 has joined #crystal-lang
<n0r1x> I have a two dimensional array of Int32 that suddenly changes values to a constant
<n0r1x> wut
n0r1x has quit [Ping timeout: 260 seconds]
n0r1x has joined #crystal-lang
<n0r1x> It's like my array suddenly changes value without anything leading to it
<RX14> n0r1x, can you show code?
<FromGitter> <bew> is there a shorter way to do something like: `caller.each {|c| puts c}` ?
<RX14> @bew no
<FromGitter> <bew> ok ty
n0r1x has quit [Ping timeout: 260 seconds]
n0r1x has joined #crystal-lang
<n0r1x> It's like my array suddenly changes value without anything leading to it (excuses if this is a double post since my internet keeps falling out)
<RX14> n0r1x, can you show some code?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<n0r1x> and I call it here
<RX14> there's a subtle bug in your initialization of @sampled
<RX14> in that all of the rows in the image are the same array
<RX14> because you set the default to a new array, and arrays are passed by reference you have an array of the same arrays
<RX14> you need to use `Array(Array(Int32)).new(@canvas.width) { Array(Int32).new(@canvas.height,0) }`
<RX14> which will create a new array instance for every row
Ven has joined #crystal-lang
<n0r1x> thank you very much RX14
Ven is now known as Guest84346
<RX14> not sure if it's the problem but it's the first bug I saw lol
<RX14> and it sounds about right
<n0r1x> it's getting somewhere http://imgur.com/a/U8jLw
<n0r1x> it's obviously rotated
<FromGitter> <schoening> I've used the three.js library in javascript quite a lot. Any recommendations for crystal? Something that supports loading 3d models and animate them? Or is there no such thing yet
<RX14> there's probably nothing like it yet
<FromGitter> <l3kn> @n0r1x: Swapping lines 22 and 23 should fix the rotation, you need to iterate over each line (y) first, then over each pixel in the line (x)
Guest84346 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
unshadow has quit [Quit: leaving]
<FromGitter> <l3kn> @schoening: Rendering the model to a gif file should be possible without too much work
<FromGitter> <schoening> Nah I want full on 3d 😊
<n0r1x> FromGitter, already fixed that one, but thank you :)
<FromGitter> n0r1x, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
bjz has joined #crystal-lang
n0r1x has quit [Quit: Page closed]
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest99943
Guest99943 has quit [Client Quit]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
splitty__ has quit [Quit: Leaving]
splitty_ has joined #crystal-lang
Qchmqs has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
domgetter has joined #crystal-lang
<domgetter> Is it possible to pass a "lambda" to map?
<domgetter> The compiler says "cannot be used as a Proc argument type yet, use a more specific type", but I don't know what it means by 'more specific type'
<BlaXpirit> domgetter, why dont you show code
<domgetter> (0..5).map(-> (n : Int) { n.even?})
<domgetter> I know in this case I can just do &.even?, but I was trying to learn for the general case of passing procs to map
<BlaXpirit> uh good that you know then
<domgetter> BlaXpirit: for the record, I'm only 3 days into Crystal, so I apologize for wasting time on something that might appear silly
<BlaXpirit> i don't think this even works. if it expects a block, then it expects a block
<domgetter> Ah okay, so it's not like Ruby where I can pass a proc as a block?
snsei has joined #crystal-lang
<RX14> domgetter, you can
<domgetter> One iteration of my code was (0..5).map(&-> (n : Int) { n.even?})
<RX14> you can use &proc to pass a proc as the block
<domgetter> That should have been the one I pasted when you asked, BlaXpirit
<RX14> the error is that you can't use Int as an argument
<RX14> you have to be more specific
<RX14> i.e. Int32
<domgetter> ahh
<RX14> for the proc
<domgetter> I thought it was referring to the proc itself
<domgetter> thank you for the clarification
<RX14> it kind of is referring to the proc itself
<RX14> not it's usage
<BlaXpirit> yeah it works then, sorry
<domgetter> It works!
<RX14> nice
<BlaXpirit> I would guess that this & internally is equivalent to { |n| (->(n : Int32){ n.even? }).call(n) }
<RX14> yup
<RX14> says almost exactly that in the docs
<BlaXpirit> not easy to find these docs, if you're not already reading through all of it
<domgetter> I'm loving the way that Crystal deals with parameters and the &.method(args) syntax
<RX14> this is where it's documented BlaXpirit
<FromGitter> <KCreate> If I have an enum `enum Reg : UInt8`, how can I use the enum values in places where a UInt8 is expected?
<RX14> enum.value iirc
<FromGitter> <KCreate> Thanks
<FromGitter> <KCreate> BTW, what's the rationale behind not allowing `enum : UInt8` values in places where UInt8 values are expected?
balduin has joined #crystal-lang
balduin has left #crystal-lang [#crystal-lang]
greengriminal has joined #crystal-lang
<domgetter> FromGitter: I can see an argument that enums are supposed to un-magicify magic numbers, so their type is the type of the enum, not of the type of the number it's wrapping, since that was the confusion in the first place
<FromGitter> domgetter, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<domgetter> Oh, that was to KCreate then
<FromGitter> <sdogruyol> @domgetter welcome to Crystal :P Hope you enjoy it
<domgetter> Thank you :) My goal is to see how nicely it can be used to make a game engine.
<FromGitter> <sdogruyol> that should be possible, Gc might be an issue
<FromGitter> <sdogruyol> or not :P
<RX14> if you stick to exclusively struct in the main frame loop it should be fine but that's quite hard to enforce
<RX14> hopefully we'll be able to turn off the GC for periods like go
<RX14> and just say "don't GC in this block"
<FromGitter> <sdogruyol> can you do that in go?
<RX14> yes
<domgetter> Well I'm sure the framerates will be faster than if written in Ruby
<FromGitter> <sdogruyol> cool, didnt know that
<FromGitter> <sdogruyol> that's for sure
<RX14> that would be super nice in conjunction with a young generation per-fiber as you could have the GC toggle be per-fiber i guess
<RX14> not sure about that
<domgetter> Doesn't GC.disable turn off GC? Or are you talking about the compiler creating code that does it for me in a nice fashion?
<RX14> oh, GC.disable exists
<RX14> i guess a GC.disabled block would be nice
<RX14> which is essentially this: def GC.disabled; GC.disable; begin; yield; ensure; GC.enable; end; end
<domgetter> Seems like I could make a with_no_GC macro or something to that effect
<RX14> doesn't need to be a macro
<domgetter> right, because block syntax already covers the boilerplate problem
<RX14> exactly
greengriminal has quit [Quit: Leaving]
<RX14> always do it without macros first
<RX14> then think hard about it to amke sure it's as beautiful as possible without macros
<domgetter> But then I'll never learn how to use macros :(
<RX14> then find places of duplication and write the simplest possible macro
<RX14> domgetter, if you can get through crystal without ever writing a macro thats a positive :)
<RX14> but yeah, of course learning macros is different
<RX14> though this isn't a good place to use macros
<RX14> as you don't need AST access
<domgetter> RX14: your advice will not go unheeded
<RX14> it's @asterite's advice, just passed through me
Raimondii has joined #crystal-lang
<FromGitter> <elorest> I posted another stack overflow question, partly for my own edification and partly because it there are probably a lot of other people with similar questions. http://stackoverflow.com/questions/43032865/im-trying-to-understand-unix-sockets-and-with-fibers-in-crystal
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<BlaXpirit> elorest, does not look like a question at all, which warrants for closing it by their rules
<FromGitter> <fridgerator> "What is the connections between UNIXServer and UNIXSocket? "
<FromGitter> <elorest> Good to know. I'll go add more question marks.
<RX14> @elorest you want to create a single UNIXServer, then call server.accept to accept a connection
<RX14> the client uses unixsocket correctly
<RX14> well, maybe it could be a bit neater and use the block form but that's just good practice
<FromGitter> <RX14> @elorest ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=58d80acac4ac989f3cb708e4]
<RX14> damnit gitter
<FromGitter> <elorest> Ok. I would have asked it here but I've seen @asterite mention a few times in git issues that I would be good to flesh out the Stack-Overflow crystal-lang tag.
<FromGitter> <sdogruyol> nice idea @elorest
<FromGitter> <RX14> @elorest ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58d80b0f7b553c707c50d576]
<RX14> gitter is terrible why am I bothering
<FromGitter> <sdogruyol> lol i like gitter
<RX14> i should write a nice shell script to open emacs and automatically gist it on close and copy the link to the clipboard
<RX14> so I could just keyboard shortcut a code scrathpad
<FromGitter> <elorest> Yeah that's a pretty good idea. I'm still on vim but should do the same thing.
<RX14> I can SPC g g B to gist a buffer already... I guess just a keyboard shortcut to a acratch file would be nice
<FromGitter> <elorest> @RX14 Do I need to use Channels for anything here with sockets? I guess you're using spacemacs?
<RX14> i'm using spacemacs, yes
<RX14> no channels needed
<RX14> i'll flesh you out a full stackoverflow ansewer after i've had my dinner, BRB
<FromGitter> <elorest> @RX14 Thanks a lot. We need to make crystal the next big thing. I've been doing ruby for 11 years and it's frustrating to see elixir, node, rust, and random js libraries that don't even fill the same use case to replace it.
<FromGitter> <sdogruyol> @elorest hell yeah!
<domgetter> elorest I think you're just missing conn = server.accept; message = conn.gets
<FromGitter> <elorest> Thanks. That's what I gathered from what @RX14 posted above. I'll have to reread the difference between accept and accept?
<domgetter> elorest one returns UNIXSocket, the other returns UNIXSocket or Nil
<domgetter> Should the docs be changed for UNIXServer to show that a connection needs to be created first?
<FromGitter> <elorest> I think so because that was confusing to me.
bjz has joined #crystal-lang
<FromGitter> <renich> Hello, I'd like to have a yaml file with multiple levels for configuration, but would love to access the values in *settings.credentials.key* form
<FromGitter> <renich> how should I read the file to map this?
<domgetter> Is there any way to make something like an Enumerator in Ruby? https://gist.github.com/domgetter/472d5d1c3fe245b227dee89da1cb388c
<domgetter> Or do I need to make a class that includes Iterator?
<FromGitter> <tzekid> Couldn't you do that w/ the help of a macro ?
<kodo[m]> > if you stick to exclusively struct in the main frame loop it should be fine but that's quite hard to enforce
<kodo[m]> What does that mean?
<kodo[m]> Do structs not GC or something?
<RX14> kodo[m], no, structs are allocated on the stack
<RX14> and passed by value
<kodo[m]> Should that be a common thing I do or just when I need GC control?
<domgetter> kodo[m]: Probably only when you need super-duper fine-tuned performance controls. Like for a video game engine
<kodo[m]> Ok :)
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
RX14 has quit [Ping timeout: 252 seconds]
RX14 has joined #crystal-lang
bjz has joined #crystal-lang
<domgetter> Is there any construct in Crystal that I can yield to that yields back? Sort of like Ruby Fibers?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> no, there isn't
<RX14> it would be nice i just don't think anyone's brough it up yet
<RX14> brought*
<RX14> although
<RX14> isn't that just channels?
<RX14> spawn a fiber which writes to a channel
<RX14> use channel.read on the other end
<RX14> yeah thats why we don't have them
<domgetter> I'll try it out
<FromGitter> <mjago> still makes me smile how easy it is binding to C in Crystal :smile:
<FromGitter> <mjago> I think its a real selling point
<FromGitter> <bew> not the only one, but yeah, do-everything-in-the-universe-in-crystal :D
<domgetter> RX14: It feels a little clunky for this use case, but I got it working: https://gist.github.com/domgetter/45d72196f2fa29ace17e0b17238aa819
<FromGitter> <bew> you can use `def initialize(@chan : Whatever); end` to directly initialize the `@chan` attribute
<domgetter> bew does "Whatever" have special meaning in this context, or did you just mean whatever type goes there?
<FromGitter> <bew> no, no meaning here, I just didn't wanted to rewrite the type :stuck_out_tongue:
<FromGitter> <bew> nice code though
<domgetter> bew thanks! I want to be able to write it this way: https://gist.github.com/domgetter/45d72196f2fa29ace17e0b17238aa819#file-loops-cr
<domgetter> But I fear that means I'll have to implement that version of Iterator#new myself
<domgetter> scratch that. Iterator is a module
<kodo[m]> so weird. `puts event.content["body"]?.inspect` is `"ping"`. `puts (event.content["body"]? =~ /ping/).inspect` is `nil`
<FromGitter> <mjago> Just noticed the spinning crystal logo on the Crystal homepage - neat!
<kodo[m]> OOOOOH
<kodo[m]> value is JSON::Any
<kodo[m]> not String
<kodo[m]> seems like calling `=~` on JSON::Any should raise exception instead of returning nil?
<kodo[m]> unless there is an actual use case for that?
<FromGitter> <elorest> @RX14 I'm still having some issues with spawning. If I start a 2 clients and answer what my name is on the second one it works but if I go back to the first one and enter my name the socket server errors with https://dl.dropboxusercontent.com/s/rc7jvcsls4vfcvv/2017-03-26%20at%205.07%20PM.png
<FromGitter> <elorest> @RX14 Here's my code that mostly works except with multiple spawns. https://dl.dropboxusercontent.com/s/t2s15spcotykv7e/2017-03-26%20at%205.10%20PM.png
<FromGitter> <bew> domgetter: maybe not another Iterator.new, but as a starting point I think you can add a `Iterator.from_data(&block)` method..
<FromGitter> <bew> domgetter: in fact you can write it like that, which is very close to what you want: https://gist.github.com/bew/de1741e55c06580db6a535d53e9b7a6b
<FromGitter> <bew> ah I see the issue, it's not incremental...
<FromGitter> <bew> I need to create a struct for single use in a macro, how do I name this struct ?
fenicks has joined #crystal-lang
<FromGitter> <bew> currently I'm hacking it like: `struct C%some_struct; end; a = C%some_struct.new` (`C%some_struct` expands to `C__temp_22`)
<FromGitter> <bew> the capital `C` is needed so the struct name is recognized by the lexer as a `:CONST`