ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.23.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<ragmaanir> ok, found a way: use "aha" to convert to html and then wkhtmltoimage to convert html to png
<FromGitter> <simaoneves> thanks for the ideas guys
<hightower2> Hey, how could I make the example on https://play.crystal-lang.org/#/r/2i5u work? I want a method that accepts a double splat, but also have it either match the method when called with no arguments, or provide an overload with no arguments which sends a dummy argument to the other one
chimkan has joined #crystal-lang
<FromGitter> <doughsay> is it possible to "subclass" a Tuple of specific types? Like I want to name and add new methods to Tuple(Int32, Int32)...
ragmaanir has quit [Quit: Leaving]
chimkan has quit [Ping timeout: 240 seconds]
<FromGitter> <doughsay> where are these "hints" or "flags" documented? like `@[Packed]`?
<FromGitter> <doughsay> it looks like `@[Flags]` is documented on the Enum page (https://crystal-lang.org/docs/syntax_and_semantics/enum.html) but `@[Packed]` is not mentioned anywhere on the Struct page...
<hightower2> doughsay: for subclassing Tuples, I would say it's not possible since Tuples are structs, which can't be subclassed
<FromGitter> <luislavena> @doughsay AFAIK `@[Packed]` can only be applied to structs within `lib` definitions (when binding with C libraries).
<FromGitter> <luislavena> And I believe works the same way as C (structure padding and packing)
hightower2 has quit [Ping timeout: 240 seconds]
hightower2 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
sp4rrow has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<FromGitter> <doughsay> @luislavena it seems to work though, with non-lib structs. Or at least it doesn't error. Also, the only reason I learned about it was from this shard: https://github.com/Papierkorb/cannon, which implies you can use it on regular structs.
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 260 seconds]
<FromGitter> <codenoid> router.cr wont work with crysta version 0.23.0 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=598bc6592723db8d5e8dd6a6]
snsei_ has joined #crystal-lang
snsei has quit [Read error: Connection reset by peer]
<FromGitter> <codenoid> best, 7000 + anime (page) served with Crystal and router.cr ⏎ http://anime.jihantoro.net/
hightower3 has quit [Ping timeout: 240 seconds]
snsei_ has quit [Remote host closed the connection]
<shelvacu> Is there a way to create a slice and allocate the memory without initializing it?
cyberarm has quit [Quit: ZNC - http://znc.in]
cyberarm has joined #crystal-lang
<shelvacu> I guess the real question is: Is there any better/more proper way than "Bytes.new(GC.malloc(i),i)"
sp4rrow has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Client Quit]
snsei has joined #crystal-lang
<watzon> shelvacu: not sure. Maybe oprypin or Papierkorb would know? They seem to know a lot
tdc has joined #crystal-lang
snsei has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<FromGitter> <bararchy> I'm so making Crystal binding for that ! ⏎ https://deepmind.com/blog/deepmind-and-blizzard-open-starcraft-ii-ai-research-environment/
thews has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
mark_66 has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Client Quit]
<FromGitter> <bew> shelvacu: you can use `Bytes.new(5)`, this will allocate memory of 5 byte, and return a slice to you on that memory
<shelvacu> bew: And also initialize it, which I don't want for performance.
<FromGitter> <bew> Then you won't find a better way to do what you want
<FromGitter> <bew> Directly using `GC.malloc` will do it.
<shelvacu> Good to know, thanks.
<shelvacu> Seems like there should be a better (and/or more obvious?) way to do it, for awhile I didn't even know about `GC`
tdc has quit [Read error: Connection reset by peer]
tdc has joined #crystal-lang
<FromGitter> <bew> shelvacu: I wonder why you need that though, the initialization is done by a memset, which is usually not a big performance issue
<shelvacu> Ah, I am indeed doing the undoubtfully bad premature optimization in my case.
<FromGitter> <bew> I see, at least you know it :)
alex`` has quit [Quit: WeeChat 1.9]
<FromGitter> <Qwerp-Derp> @oprypin How would you compile a CrSFML project so that it can be distributed?
<FromGitter> <bararchy> @Qwerp-Derp I think you should bundle the SFML statis libs or something, or just add it as a dependency to running the game ?
<FromGitter> <Qwerp-Derp> Don't I have to bundle the version of CSFML (VoidCSFML) that CrSFML uses with the game that I'm distributing, which requires CMake?
<FromGitter> <bararchy> Well... maybe @oprypin has a better idea :)
Yxhuvud has quit [Ping timeout: 255 seconds]
<FromGitter> <Qwerp-Derp> I have a feeling that my question might be a somewhat stupid question, but there doesn't seem to be a way to create a standalone application listed in oprypin's tutorials
<FromGitter> <bararchy> It's not a stupid question, i guess static linking is the best way to go, but I'm sure @oprypin can tell us if he has a better approch
<FromGitter> <bew> what do you mean by "distributed"? you mean just ship some binaries and there dependencies? or you want to ship the code for others to compile & run?
<FromGitter> <Qwerp-Derp> I want to ship a standalone binary or executable.
DTZUZO has joined #crystal-lang
<FromGitter> <Qwerp-Derp> @bew?
<FromGitter> <bew> yes?
thews has joined #crystal-lang
thews has joined #crystal-lang
thews has quit [Changing host]
<FromGitter> <Qwerp-Derp> Do you have any ideas as to how to create a standalone binary?
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <Qwerp-Derp> @bew Yes or no?
<oprypin> i haven't done static linking on Linux
<oprypin> on my blog post about crsfml on Windows everything is statically linked
<shelvacu> I think you just pass -static to the linker, but I haven't done it.
<shelvacu> I think for crystal specifically it's /complicated/
<oprypin> on Linux i would recommend shipping libsfml*.so and libvoidcsfml*.so together with your program
<oprypin> probably don't link everything into the executable, that sucks
<oprypin> u need cmake only to build the libs
<FromGitter> <bararchy> So, Regexfuu question ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Any ideas ? :) [https://gitter.im/crystal-lang/crystal?at=598c2411a7b406262d759484]
<oprypin> so yeah make a folder with bundled libs and run your executable as LD_LIBRARY_PATH="$(pwd)/libs" ./game
<oprypin> pls no regex
<oprypin> use an uri parser
DTZUZO has joined #crystal-lang
<oprypin> replace with =bar\2 or use lookahead
<oprypin> that's if u insist on regex
<oprypin> https://crystal-lang.org/api/0.23.1/URI.html#query%3AString%3F-instance-method https://crystal-lang.org/api/0.23.1/HTTP/Params.html#parse%28query%3AString%29%3Aself-class-method proper solution
<FromGitter> <bararchy> Well, in opose to Ruby where URI.parse returns a parameter hash, in Crystal I get this: @query="from=2017-07-11&show_wiki_edits=1", so still a string lol
<FromGitter> <bararchy> Oh ok
<FromGitter> <bararchy> need to use another part for that
<FromGitter> <bararchy> Doesn't it make more sense to add auto `HTTP::Params.parse` for the query in URI parse ?
hightower3 has joined #crystal-lang
<oprypin> perhaps
<FromGitter> <bararchy> oprypin, much better then Regex ... lol ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=598c2833bc464729746d7501]
<watzon> I agree actually
bmcginty has quit [Ping timeout: 240 seconds]
bmcginty has joined #crystal-lang
xiljin has quit [Quit: ...]
office_boy has joined #crystal-lang
<office_boy> hey
office_boy has quit [Client Quit]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
office_boy has joined #crystal-lang
<office_boy> How do you precompile assets for a kemal app if you're deploying to Heroku?
Yxhuvud has joined #crystal-lang
_whitelogger has joined #crystal-lang
xiljin has joined #crystal-lang
<FromGitter> <bararchy> Can the Crystal logger do log_rotate by himself ?
office_boy has quit [Remote host closed the connection]
office_boy has joined #crystal-lang
office_boy has quit [Read error: Connection reset by peer]
office_boy has joined #crystal-lang
office_boy has quit [Read error: Connection reset by peer]
office_boy has joined #crystal-lang
office_boy has quit [Read error: Connection reset by peer]
gewo has joined #crystal-lang
<FromGitter> <bew> @bararchy I don't think so
tdc_ has joined #crystal-lang
tdc has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<jokke> hey!
<FromGitter> <LuckyChicken91_twitter> heyy!
<jokke> how would i generate an xml document from scratch?
<jokke> there's no XML::Document clas
<jokke> s
<jokke> oh
<jokke> i'm just stupid
<jokke> there's XML::Builder :D
<FromGitter> <LuckyChicken91_twitter> from scratch?!
<FromGitter> <LuckyChicken91_twitter> dont use scratch
<FromGitter> <LuckyChicken91_twitter> scratch is for kids
<watzon> 😂
office_boy has joined #crystal-lang
sz0 has joined #crystal-lang
office_boy has quit []
snsei has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<FromGitter> <LuckyChicken91_twitter> can someone explain me `spawn`
<Papierkorb> What's not clear about it?
<FromGitter> <LuckyChicken91_twitter> i dont know what its doing
<Papierkorb> ... Have you read its documentation?
<FromGitter> <LuckyChicken91_twitter> okay will read it now
<FromGitter> <LuckyChicken91_twitter> thanks for the tip
<Papierkorb> ....
<FromGitter> <LuckyChicken91_twitter> uuh wheres the documentation
<Papierkorb> Really. Look at the docs. Do you think it's nice to use to make us waste time when you didn't do your part?
<FromGitter> <LuckyChicken91_twitter> i entered "spawn" in the doc search thing
<FromGitter> <LuckyChicken91_twitter> but nothing appears
<watzon> http://devdocs.io/crystal/api/0.23.0/toplevel#spawn(*,name:String?=nil,&block)-class-method
<Papierkorb> https://crystal-lang.org/api/0.23.1/toplevel.html#spawn%28%2A%2Cname%3AString%3F%3Dnil%2C%26block%29-class-method
<FromGitter> <LuckyChicken91_twitter> oh devdocs.io is better than the normal docs thing from crystal
<FromGitter> <LuckyChicken91_twitter> i will use devdocs always now
<FromGitter> <bew> you can also read about concurrency here: https://crystal-lang.org/docs/guides/concurrency.html
<watzon> Devdocs has just about everything
<watzon> One stop shop
<FromGitter> <LuckyChicken91_twitter> help im getting `Invalid memory access (signal 11) at address 0x10`
<FromGitter> <LuckyChicken91_twitter> i just wrote normal working code
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <bew> it doesn't seems to work.. you'll need to give us more context if you want any help
<FromGitter> <LuckyChicken91_twitter> https://carc.in/#/r/2iaa/edit
<FromGitter> <LuckyChicken91_twitter> here
<FromGitter> <LuckyChicken91_twitter> i think its a bug. But im not sure
<FromGitter> <LuckyChicken91_twitter> or im just totaly bad at thread
snsei has quit [Ping timeout: 255 seconds]
<Papierkorb> Why are you suddenly jumping to `Thread`?
<Papierkorb> thread has nothing to do with `spawn`, and is incidentially not what you're supposed to used in any case
<FromGitter> <LuckyChicken91_twitter> i know that spawn has nothing to do with spawn
<FromGitter> <LuckyChicken91_twitter> why are you telling me this
<FromGitter> <LuckyChicken91_twitter> i mean with thread*
<watzon> Papierkorb: Theres no way to get the PID of a spawn is there?
<Papierkorb> watzon, well a Fiber isn't a process anyway, so the PID doesn't change
<watzon> Good point. But you can't assign a spawned fiber to a variable can you?
<FromGitter> <LuckyChicken91_twitter> well why is this code wrong now?
<watzon> Like `fiber = spawn do ... end`
<FromGitter> <LuckyChicken91_twitter> i just want to use a thread so that he is executing this code while the gets
<FromGitter> <LuckyChicken91_twitter> so that the npc is having a chance too to win
<Papierkorb> watzon: Sure you can
<FromGitter> <LuckyChicken91_twitter> can someone tell me now whats wrong with my code
<Papierkorb> watzon: Not much you can do with it though ;)
<FromGitter> <LuckyChicken91_twitter> somebody knows it
<FromGitter> <oprypin> io
<watzon> Well can you at least close it that way? Say `fiber.exit` or something?
<oprypin> your code doesn't work because you use Thread
<FromGitter> <LuckyChicken91_twitter> ooh
<FromGitter> <LuckyChicken91_twitter> but why cant i use a thread
<Papierkorb> watzon: No, we don't support that, as in that case the fiber wouldn't have a chance of releasing resources, or more general: Leaving the application in a coherent state
<oprypin> watzon, why would you forcibly stop code without any kind of cleanup?
<watzon> Makes sense. I don't really have a reason per-say, just curious
<oprypin> why did you think you can use Thread?
<Papierkorb> watzon, E.g., consider when a fiber would grab a mutex, and then wait for some #read to return. Killing it while in that #read blocking state would deadlock your application.
<FromGitter> <LuckyChicken91_twitter> so i need to use `spawn` now
<FromGitter> <LuckyChicken91_twitter> ?
<oprypin> probably neither
<FromGitter> <LuckyChicken91_twitter> oh wow `spawn`s are amazing
<FromGitter> <LuckyChicken91_twitter> they are working so easy
<FromGitter> <LuckyChicken91_twitter> now i will never use thread again
<oprypin> ...
<watzon> Lol
<oprypin> well for Crystal that's actually a good idea but you said that having no context
<FromGitter> <LuckyChicken91_twitter> i said that `spawn` is having no context?
<FromGitter> <bew> no he meant: you said "I will never use thread again" without the context that you're writing Crystal. Actually threads are good in most other languages.
<FromGitter> <LuckyChicken91_twitter> oooh
<FromGitter> <LuckyChicken91_twitter> yes so i will continue using threads
<FromGitter> <bew> ...
<Papierkorb> The moment you realize that talking to a wall is more productive
<FromGitter> <LuckyChicken91_twitter> :(
<FromGitter> <fridgerator> I for one, have smiled several times and LOL'ed once because of @LuckyChicken91_twitter, i'm glad he's in this channel
<FromGitter> <bew> @straight-shoota for the sake of correctness in your comment in https://github.com/crystal-lang/crystal/issues/4820#issuecomment-321597995 you meant `with the included macro hook` not `inherited`
<FromGitter> <straight-shoota> thanks bew, fixed it
<FromGitter> <LuckyChicken91_twitter> someone here maybe know an old western shooter game?
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <LuckyChicken91_twitter> how can I add something to the beginning of a string?
<FromGitter> <LuckyChicken91_twitter> `str += "hello"` is just adding the "hello" to the end of `str`
<FromGitter> <fridgerator> `"hello#{str}"`
<FromGitter> <LuckyChicken91_twitter> nono this was just an example
<FromGitter> <LuckyChicken91_twitter> i want to add 10 times an " " to the beginning of a string
<FromGitter> <LuckyChicken91_twitter> with 10.times.do
<Papierkorb> x = 10; str = (" " * x) + str
<FromGitter> <LuckyChicken91_twitter> oh okay
office_boy has joined #crystal-lang
<jokke> isn't it possible to nest macro expressions anymore?
<jokke> i basically want to loop over the result of a run() method in a macro
<FromGitter> <faustinoaq> > I for one, have smiled several times and LOL'ed once because of @LuckyChicken91_twitter, i'm glad he's in this channel ⏎ ⏎ 👍 I like the good sense of humor that crystal community have 😄
tdc_ has quit [Read error: Connection reset by peer]
tdc_ has joined #crystal-lang
office_boy has quit []
<FromGitter> <straight-shoota> nice
<FromGitter> <straight-shoota> jokke, should still be possible.
<jokke> yeah i just found out
Poeticode has joined #crystal-lang
tdc_ has quit [Quit: Leaving]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
A124 has quit [Ping timeout: 240 seconds]
<watzon> That solution isn't perfect, but it's about the only thing you can do until crystal is avaliable for windows or vscode builds WSL functionality in somehow
A124 has joined #crystal-lang
<FromGitter> <bew> RX14: why you don't like this syntax? https://github.com/crystal-lang/crystal/pull/4811#commitcomment-23584176 it seems that `while` is not used a lot, is there a reason?
<watzon> His suggestion is easier to reason about
<watzon> At least I think so
<FromGitter> <bew> Hmm that's possible
A124 has quit [Quit: '']
A124 has joined #crystal-lang
<FromGitter> <faustinoaq> Interesting 😄 https://gitter.im/crystal-scry/Lobby
<FromGitter> <faustinoaq> https://github.com/crystal-lang-tools
<FromGitter> <faustinoaq> from Nim Gitter: ⏎ ⏎ > (Offtopic: NimBot should have a !createissue <msg> command) ⏎ ⏎ Does CrystalBot have something similar? [https://gitter.im/crystal-lang/crystal?at=598cb32e329651f46e0a9468]
<FromGitter> <faustinoaq> Would be awesome 😄
<oprypin> there is no crystalbot at the moment
<oprypin> seems like a terrible idea, as well
<oprypin> (createissue)
<FromGitter> <faustinoaq> oprypin: then what is DeBot for? https://github.com/jhass/DeBot
<oprypin> for a lot of things but it's inactive at the moment
<FromGitter> <LuckyChicken91_twitter> is still nobody working on an gui framework
<FromGitter> <chuckremes> We are waiting for you to start the work, @LuckyChicken91_twitter!
<FromGitter> <elorest> Is there any more progress on multithreading? Seems windows support is moving forward but most people I talk to about crystal couldn’t care less about windows support.
<FromGitter> <LuckyChicken91_twitter> eeemm.. how could i start?
<FromGitter> <LuckyChicken91_twitter> @elorest im on windows
<FromGitter> <elorest> lol why?
<FromGitter> <LuckyChicken91_twitter> and i also dont care about windows support
<FromGitter> <LuckyChicken91_twitter> because im easily using linux subsystem on windows!
<FromGitter> <elorest> 😄
<FromGitter> <elorest> Does top work on that yet?
<FromGitter> <chuckremes> @LuckyChicken91_twitter you could start by finding your favorite GUI library and start writing some bindings for it. Crystal makes it (almost) easy!
<FromGitter> <LuckyChicken91_twitter> its okay to use crystal on linux subsystem
<watzon> Yes
zaiste has joined #crystal-lang
<oprypin> elorest, personally to me it seems like only Manas has the ability to push both of these efforts over the threshold, but they're stalling or at least not being public about their work
<oprypin> chuckremes, making bindings for any decent GUI library is without doubt the most difficult of any bindings
<watzon> Yeah that's the one thing that worries me about Crystal
<watzon> It's an awesome language, but we need a bit more communication
<FromGitter> <faustinoaq> > Is there any more progress on multithreading? ⏎ ⏎ @elorest Seems that core developers are working hard on it. ⏎ ⏎ Remember it 👉 https://github.com/crystal-lang/crystal/wiki/Threads-support#random-notes ... [https://gitter.im/crystal-lang/crystal?at=598cb89776a757f80891f6b1]
<FromGitter> <chuckremes> when making any bindings is pretty simple with Crystal, that isn’t saying much. It’s certainly non-trivial to get all of the use-cases working, but my bet is that most users of such a library want to do fairly simple things. Getting the simple stuff working (putting up windows, dialogs, handling text entry) is fairly straight forward. But YMMV.
<oprypin> faustinoaq, they WERE working hard on it. no updates in 4 months
<FromGitter> <faustinoaq> yes, I know 😅
<FromGitter> <faustinoaq> Hey people, What do you think of 👉 https://groups.google.com/forum/#!topic/crystal-lang/uITftLnpl_0 ?
<FromGitter> <fridgerator> and in those 4 months, all the stuff with asterite, makes me worry too
<FromGitter> <LuckyChicken91_twitter> i hope for a good future for crystal
<FromGitter> <faustinoaq> Did I do bad on ask about bountysource?
<FromGitter> <LuckyChicken91_twitter> oh they got $ 2 242.00 money
<oprypin> you can't do it without sounding bad but it has to be done
<oprypin> what you did bad is making the example look official
<oprypin> and of course LuckyChicken91_twitter immediately gets confused
<FromGitter> <LuckyChicken91_twitter> wat
<FromGitter> <faustinoaq> @fridgerator I hope to see @asterite time to time at least in some place talking about Crystal.
<oprypin> i'm very critical of this, you can't accept contributions while keeping absolutely quiet for months
<FromGitter> <LuckyChicken91_twitter> oh yes! this is true
<FromGitter> <LuckyChicken91_twitter> what are they doing with our money?
<FromGitter> <faustinoaq> <oprypin> lol
<oprypin> Papierkorb, how's Qt coming along
<FromGitter> <faustinoaq> @LuckyChicken91_twitter calm down, core developers are working hard, don't be afraid, Crystal is open source, we all can collaborate.
<FromGitter> <LuckyChicken91_twitter> aah very good
<oprypin> faustinoaq, well... yes and no. what with perfectly good pull requests laying around for months
<FromGitter> <LuckyChicken91_twitter> crystal needs much time to think
<FromGitter> <faustinoaq> oprypin: I think core developers need to understand well and discuss opinions before merging PRs taking a lot of time in some cases.
<FromGitter> <LuckyChicken91_twitter> i hope they will understand someday that they should add multiline comments
<oprypin> lol
<FromGitter> <faustinoaq> lol
<FromGitter> <fridgerator> maybe for 2.0
<oprypin> you can use %{ } if you really want ugly multiline comments
<FromGitter> <faustinoaq> or ⏎ ⏎ <<-COMMENT ⏎ This is a multi line comment ⏎ COMMENT [https://gitter.im/crystal-lang/crystal?at=598cbc224bcd78af563072aa]
sz0 has joined #crystal-lang
<FromGitter> <elorest> Sort of I guess I've been in ruby too long but I'm find with ⏎ ⏎ ```# comment 1 ⏎ # comment 2 ⏎ # comment 3``` [https://gitter.im/crystal-lang/crystal?at=598cbc5bbc464729747000e4]
<FromGitter> <faustinoaq> @fridgerator talking about 2.0, you remember me to ask, What are the goals for Crystal after 1.0?
<oprypin> faustinoaq, they have not been stated
<oprypin> performance and documentation is obviously good to revisit at that point
<oprypin> but a lot will change before it gets to that point
<oprypin> i remember seeing some explanation of `select`, with the code it gets rewritten to. am i making things up?
<FromGitter> <faustinoaq> @elorest 👍
<oprypin> bleh seems like https://github.com/crystal-lang/crystal/pull/3130 is all we have
<RX14> @bew using a while loop is correct, squeezing both the assignment and the includes check into 1 line is overly confusing
<RX14> and I didn't twig that @dir.next was nillable either
<FromGitter> <bew> Yeah that I can understand
<FromGitter> <bew> Thanks for the reply
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bew> is there a way to make like a Go's defer in specs? e.g. I have a specific spec that needs to have initialization & teardown steps, and I want the teardown steps to always execute after the spec finish (success or failure)
<RX14> @bew no, unfortunately not
<RX14> however if you hjave a setup and teardown action
<RX14> that hints that you're trying to construct a resource which needs a teardown step
<RX14> just create a helper method which creates the resource and has a finally block which tears it down
<RX14> and yields the resource
<FromGitter> <bew> that's interesting! I'm working on #4691 with specs like this: https://github.com/crystal-lang/crystal/blob/master/spec/compiler/crystal/tools/init_spec.cr#L164-L168
<FromGitter> <bew> thanks
<RX14> yup
<RX14> so you;re yielding a tempoart resource: a diredctory
<RX14> wow that was all the wrong fingers in the wrong places on my keyboard
<FromGitter> <bew> x)
<FromGitter> <Qwerp-Derp> @faustinoaq Maybe add something to your VSCode plugin so that when you have a comment and press Enter, the next line automatically starts a comment?
<oprypin> sounds terrible
zaiste has joined #crystal-lang
<FromGitter> <Qwerp-Derp> @oprypin I'm actually working on Mac OS X, so I have no idea where to find the .so files...
<oprypin> Qwerp-Derp, so you installed all libs globally?
<oprypin> cant help but wonder why nobody uses the recommended approach and goes for approach 2
<FromGitter> <Qwerp-Derp> Yep
<oprypin> gotta delete it probably or something
<FromGitter> <Qwerp-Derp> I think you should include the instructions for this in your main GH directory for CrSFML :P
<oprypin> it's kinda common knowledge
<FromGitter> <Qwerp-Derp> Wait so I have to delete the versions I created using CMake?
<FromGitter> <Qwerp-Derp> I have 0 experience with C, so it's not exactly common knowledge for me
<FromGitter> <Qwerp-Derp> And I have limited experience with Bash and Mac OS X
<hightower3> Does Crystal behave the same as Ruby in the sense that it's useful to make methods which create and return blocks, to essentially have empty/clean local context in the new method, so that the block wouldn't keep references to all local vars that were in scope when block was created?
<oprypin> no idea what u mean
<hightower3> If I do def myfunc; a=1; b=2; someotherfunc() { my block } end ... Will the block passed keep references to 'a' and 'b' ?
<hightower3> (i.e. even if they are not explicitly used in the block)
<oprypin> hightower3, it keeps references only to what's .. referenced
<oprypin> but let's say it did keep references to everything, how does that change anything at all?
<hightower3> If I store the block in some long-term store (like an instance variable), then it makes all these objects remain in memory indefinitely, even though the calling function exited
<hightower3> (if it would keep references to all objects, that is)
<hightower3> Papierkorb, there by chance?
<oprypin> hightower3, something seems off in your reasoning but i can't tell what, so you're probably right.
<oprypin> Qwerp-Derp, so uh preferably remove the globally installed stuff, do approach 1, then u have all the .so files at your fingertips. put them in the same folder as the executable and run LD_LIBRARY_PATH="$(pwd)" ./my_game
<oprypin> or i dont know, scour /usr/local for unoptimized globally installed libs
<oprypin> wait you dont even have .so files, that's dylib
<oprypin> i actually have no idea what happens on mac
<oprypin> or if it even has ld
<oprypin> hightower3, i don't see any reason for worry though, you never want to not keep references to variables you're using
<hightower3> oprypin, yes, I was asking about the ones I don't use. But since you answered that the ones not mentioned are not kept referenced, it's all good.
<hightower3> s/not mentioned/not used/
<Papierkorb> hightower3: ?
<Papierkorb> hightower3: Never tried that, sounds quite micro-optimization considering that "keep your methods small" is a good code design decision in any case. Haven't digged yet into what LLVM makes out of the stored scope though - Except that it's stored effectively as class, and passed as implicit `self` into the block if that makes any sense
<hightower3> Papierkorb, I am just looking at 'cute'. My first question is how would I essentially do a one-time trigger. Second question (I am just about to look into the code), is if there exists an off() to remove the listener.
<Papierkorb> w.r.t. 1) Nope, not built-in, but easily doable through 2) Yes, `#disconnect` with the handle you got back from `#on`
<hightower3> Ok. I need to convert a signal system into Crystal which works simply in a way that it has "string signal name" => [ array of handler methods/blocks ]. I am going to mimick that using Cute by creating a common object which is aware of all signals (defines their names and accepted arguments)
<Papierkorb> Actually I only chose `#on` because it looked nicer in code than `#connect`, also to emphasize it's usage with a block. It's not loaned from "on" as is used by jQuery
<hightower3> and then simply everything calls @events.<name>.on ....
<hightower3> And in that object I'm gonna implement off transparently
<Papierkorb> I mean you could alias off to #disconnect in Cute::Signal :P
<hightower3> Right, but in my object I would also keep track of the handles received... I don't want to do that in the code that calls #on
<hightower3> And for a one-time though, I'd appreciate some hint, not sure how I'd go about it
<hightower3> (What I mean by 'keep track of handles' is I want to call off() not with a handle, but with the same block with which I called it when I called on()
<Papierkorb> Mh that should be documented...
<Papierkorb> Look in src/cute.cr lines 46ff
snsei has joined #crystal-lang
<hightower3> Sure, as you already told me. But as mentioned I want to call off() with the same block I called on() with, not with a handle I got in response to on()
<Papierkorb> The "same block" isn't possible, you'd have to get exactly the same resulting Proc which isn't possible. #on gives you a handle, which really is just `Proc#hash`
<Papierkorb> So if you're storing that Proc yourself, depending how Crystal/LLVM does it, you can just pass in that Procs #hash. Never tried that though
<hightower3> mm, yeah. I was thinking of storing procs in instance vars, but that's ugly/wrong
<hightower3> Ok
<hightower3> Ok, the question for a one-time trigger remains
<Papierkorb> try this: `def once(signal); h = 0u32; h = signal.on{|*x| signal.disconnect(h); yield *x}; end`
<Papierkorb> use like `once(@signals.something_happened) do ... end`
<Papierkorb> Signals are objects
snsei has quit [Ping timeout: 258 seconds]
<hightower3> ah, nice trick
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/v7yGg
<crystal-gh> crystal/master de80a09 TSUYUSATO Kitsune: Parser: prevent to finish a macro body when {% if/for/begin %} is nested (#4801)...
zaiste has quit [Ping timeout: 248 seconds]
<hightower3> Hey Papierkorb , how do I retrieve signal name? E.g. on every #on, I want to do what on() does, plus emit( 'newListener', <name>)
<hightower3> or rather newListener.emit( name)
<Papierkorb> Catch it like above, and then pass it on
<hightower3> To subclass the Signal's initialize to store the name?
<Papierkorb> no just store it in the blocks caught scope
<hightower3> I don't get it
<hightower3> (I would need the signal name both at #on and #off time)
<Papierkorb> no?
<Papierkorb> You *have* to use the given handle. Even a `on{}; on{}` won't give you the same handles. It's impossible to generate the exact same block *instance* again
<hightower3> Sure, that's clear
<Papierkorb> You have to have the name somewhere, and that you can just pass into the block through the scope. Signals don't have "names" at run-time anymore (unlike in Qt)
<hightower3> I don't get it. I have for example Cute.signal new_listener( event : Symbol)... and then I have subclassed on(listener) { ret = super; new_listener.emit( ...what...? ) ; ret }
<Papierkorb> ... you sub-classed the Signal_* class?
<hightower3> No, I have my module which includes Cute, and I've implemented on() in it
<hightower3> module Events; include Cute; def on (listener) ret = super; new_listener.emit( ...what...? ) ; ret end
<FromGitter> <kazzkiq> How to start mysql connection with specific character/collation?
<Papierkorb> Is that `on` supposed to be your own method, or did you try to target Cute's `#on` hightower3?
<FromGitter> <kazzkiq> utf8 don't play well with emojis. My database is using utf8mb4 as expected, but the connection made by Crystal still is utf8, which leads to errors when trying to save the data.
<hightower3> Papierkorb, that's mine, which is supposed to first call Cute's super, then emit a signal new_listener with the name of the on-ed signal as argument
<hightower3> Let me paste the code
<hightower3> Papierkorb, https://play.crystal-lang.org/#/r/2icy . The part I am missing is the <name> things
<Papierkorb> Ah. So, first, in that setup there's no `super`. Cute isn't a signal broker in the sense that there is no central unit that figures out what to send where. `Cute.signal x` generates a `Signal_x` class, and you get an instance of that when you call the generated `#x` on an object. That instance is then responsible to broadcast #emit's to all interested parties, which actually boils down to something like `list_of_procs.each{|x| x.call(...)}
<Papierkorb> `. Now, this means, all of this is static (type-safe even), at compile-time. You can't really generate a Signal at runtime - Well, that's at least not the intention. If you have a source you want to "transform" into cute signals, there are two options: 1) You don't know what signals exist at compile-time, then you have to use a single (or few) generic signals, which you can then pass the name and arguments into (That's what you get from
<Papierkorb> the foreign signal broadcaster I guess?). 2) You know exactly which signals can appear. In this case, have a signal for each, and then have a small broker (A `case` statement should suffice) to #emit the correct signal upon receiving a 'notification' from the foreign entity
<Papierkorb> hightower3: Signals have no names, apart from what you write in the sources, as in the resulting binary, it's really just doing normal OOP things. You're really using variables and objects, there's no further "broker" logic required - as far Cute is concerned
<hightower3> Papierkorb, sure, sure, I understand that. I know the signal names in advance. (They are spread throughout separate objects since not all objects can emit all the same signals).
<Papierkorb> What's your foreign source?
<hightower3> It is just that at the time on() is called, I would want to emit a special signal (new_listener) with the name of the new signal. But I can't do this because as you say, signal has no name, and it was created at the time of Cute.signal, not at the time of on()
<Papierkorb> Well you can get the name from the signals class-name, if you're fine with fiddling it out of the class name. The naming scheme is simply `Signal_x`, so doing `broker.new_listener.class.name[<something>]`, you can grab that
<hightower3> Ah, of course!
<hightower3> That'll work
<Papierkorb> Though adding that `#name` feature wouldn't be hard, I can do that later tomorrow or so.
<hightower3> Ok great, I'll count on you adding it then since it seems you agree it would be useful.
<Papierkorb> The #name stuff that is, for debugging purposes in more complex scenarios
<hightower3> Papierkorb, how would I go about disconnecting all listeners, regardless of which signal they are listening on? (Asking given the fact that signals get created as classes and there is no list of signals anywhere)
<hightower3> (disconnecting all listeners from a particular object I mean... not all objects in the program of course)
<Papierkorb> `Signal#disconnect` without an argument will remove all listeners of that signal