ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Crystal 0.22.0 | Fund Crystal's development: | Paste > 3 lines of text to | GH: | Docs: | API: | Logs:
go|dfish has joined #crystal-lang
zipR4ND1 has quit [Ping timeout: 240 seconds]
greengriminal has quit [Quit: Leaving]
sz0 has quit [Quit: Connection closed for inactivity]
Raimondii has joined #crystal-lang
snsei has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
<FromGitter> <drujensen> @RX14 how would you envision a component system that would allow for extending the HTTP::Server::Context?
snsei has quit [Ping timeout: 268 seconds]
<FromGitter> <drujensen> Here is a flash handler in Kemalyst. It adds a special hash to the HTTP::Server::Context and then uses it to keep track of flash messages.
<FromGitter> <drujensen> how could we componentize this handler so it can be re-used by other frameworks like Kemal?
snsei has joined #crystal-lang
pduncan has joined #crystal-lang
<FromGitter> <TheLonelyGhost> I'm looking at, seeing if I can scope out the amount of effort and how much of a learning curve for hooking into LibC. At this point, should I be looking at C tutorials?
<FromGitter> <TheLonelyGhost> Also looks like LibC is missing `#syscall` in `src/lib_c/x86_64-macosx-darwin/c/`. Does anyone know why?
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
yogg-saron has joined #crystal-lang
<FromGitter> <bararchy> @oprypin , I'm using your crsfml lib to write a simple game, It's quite fun , thanks for taking the time for building it :)
<FromGitter> <elorest> I’m trying to find a weird syntax documented somewhere.
<FromGitter> <bew> @elorest this is for
<FromGitter> <bew> This allows you to have an exposed name for an argument, and an internal name
<FromGitter> <bew> (used in the method body)
zipR4ND has joined #crystal-lang
Kug3lis has joined #crystal-lang
<FromGitter> <bew> Why `OpAssign` is disabled in macros ? eg.`{{ some_var += 3 }}`
Philpax has joined #crystal-lang
bjz has joined #crystal-lang
zipR4ND has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
vifino has quit [Ping timeout: 240 seconds]
vifino has joined #crystal-lang
bjz has joined #crystal-lang
<FromGitter> <crisward> @sdogruyol Does kemal ping websockets to keep them alive? I've noticed my inactive websockets close after 1 minute. Not sure if it's Chrome or Crystal which is doing this? I have some reconnect logic client side, which auto reconnect, but wasn't sure if I should add something to my crystal code to ping every 30 seconds to keep the browsers connected.
<FromGitter> <crisward> It looks like chrome which is doing the disconnect. Will add a ping to see if this keeps things connected.
<FromGitter> <crisward> I've added spawned loop with a 30 second sleep to ping all connected sockets. The reconnects have gone away.
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
kubaxvx has quit [Read error: Connection reset by peer]
kubaxvx_ has joined #crystal-lang
zipR4ND has joined #crystal-lang
<oprypin> bew, macros are intentionally limited
<oprypin> bararchy, :) i saw the issue you posted but i have no idea what could be wrong with font loading. have you tried the examples and the bundled font?
splitty__ has joined #crystal-lang
splitty___ has joined #crystal-lang
splitty_ has quit [Ping timeout: 260 seconds]
splitty__ has quit [Ping timeout: 246 seconds]
<crystal-gh> [crystal] reitermarkus opened pull request #4430: Add new `?~` (boolean `=~`) operator. (master...boolean-equal-tilde-operator)
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bew> about #4430 what are thoses operators?
<DeBot> (Add new `?~` (boolean `=~`) operator.)
<FromGitter> <bew> (`=~`, `!~`, `?~`)
<wuehlmaus> is this a bug?
<wuehlmaus> [in ruby it works with $' ]
<Papierkorb> bew, looks like an unecessary addition to the language
<wuehlmaus> i was not sure so i am asking.
<wuehlmaus> it works with the "match" method
<FromGitter> <bew> wuehlmaus: it seems that gsub does not set the special `$~` var
<FromGitter> <bew> and it is documented here:,replacement,backreferences=true)-instance-method (3rd line)
<wuehlmaus> bew: thanks
<FromGitter> <bararchy> oprypin: I get the same error for the font you get with the examples
<FromGitter> <bararchy> oprypin: Could it be because I `make` from the HEAD git and not the tar release file ?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
fazibear has joined #crystal-lang
yogg-saron has joined #crystal-lang
fazibear_ has joined #crystal-lang
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fazibear_ has quit [Quit: leaving]
snsei has joined #crystal-lang
<FromGitter> <fridgerator> @crisward its necessary to implement a "heartbeat", kemal doesn't do this for you
<FromGitter> <fridgerator> rails / phoenix / some nodejs frameworks however, have this implemented already
fazibear has quit [Quit: leaving]
<FromGitter> <bigtunacan> How do I submit a shard to
<FromGitter> <fridgerator> @bigtunacan it gets data form github automatically
<Papierkorb> It should show up within a day
<FromGitter> <bigtunacan> How does it do that?
<FromGitter> <bew> @bigtunacan you don't need to do anything, it search github every hour for new projects using crystal
fazibear has joined #crystal-lang
<FromGitter> <bigtunacan> gotcha
fazibear has quit [Client Quit]
<FromGitter> <bigtunacan> I figured just tagging something as Crystal lang isn't enough since that would include non libs
<Papierkorb> github does analysis by itself to figure out the used language(s), which you can then search for
<FromGitter> <bew> (maybe it'll open the shards.yml file, and checks it's a lib..)
<Papierkorb> no tagging necessary
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
Dreamer3 has quit [Quit: Computer has gone to sleep.]
Philpax has quit [Ping timeout: 268 seconds]
Raimondi has quit [Quit: WeeChat 1.8-dev]
Raimondi has joined #crystal-lang
<FromGitter> <crisward> @fridgerator Thanks, done that.
<crystal-gh> [crystal] akzhan opened pull request #4433: Mimics EAGAIN on EINPROGRESS error while ssl_shutdown. Fixes #3168 (master...retry-EINPROGRESS-on-unbuffered-close)
<FromGitter> <bigtunacan> @bew Thanks
<FromGitter> <bew> yw :)
<FromGitter> <bigtunacan> Guess we'll see how long it takes for them to show up
<FromGitter> <bigtunacan> Dang
<FromGitter> <bigtunacan> That was quick, lol
Dreamer3 has joined #crystal-lang
Kug3lis has quit [Ping timeout: 255 seconds]
Dreamer3 has quit [Ping timeout: 258 seconds]
balduin has joined #crystal-lang
Kug3lis has joined #crystal-lang
Kug3lis has quit [Ping timeout: 255 seconds]
<oprypin> can't find any decent way to find whether a loop ended by using `break` or not
<RX14> oprypin, what usecase?
<oprypin> break means 'aha, found it'. no break means not found. dont want to keep around a silly boolean
<oprypin> seems like my code is failing even if i do it with a boolean, too bad
<RX14> oprypin, surely you can capture the result of the while
<RX14> break <result>
<RX14> else it's nil?
<oprypin> yeah i think that works
<RX14> nice
<RX14> might need a nil at the end of the loop though
<RX14> test it
<oprypin> thanks
<oprypin> now i want a neat way to find every index in an array for which some condition is true
<oprypin> and get them in reverse
<RX14> if only #index returned an array
<oprypin> even worse for a string
<oprypin> { |i| string[i] == '?' }
<RX14> uhh
<RX14> surely the first part is just (0...string.size).to_a.reverse
<RX14> or just
<RX14> string.size.downto(0).select { |i| }
<RX14> >> "foobar".chars.each_index.to_a
<DeBot> RX14: # => [0, 1, 2, 3, 4, 5] -
<RX14> yeah
<oprypin> welp who needs indices in reverse when you can use reverse_each on them later. `(0...string.size).select { |i| string[i] == '?' } `
<RX14> (string.size - 1).downto... though
<RX14> oprypin, oh i guess lol
snsei has quit [Remote host closed the connection]
<RX14> upto/downto have iterator version though
<RX14> i think it looks cleaner than the range
<RX14> but thats personal
<FromGitter> <elorest> Thanks @bew
<oprypin> RX14, then you'd need .to_a at the end
<oprypin> cuz -> iterator
<RX14> yes but do you need that to_a
<RX14> if you're just going to revsrse_each
<RX14> if so then sure
<RX14> but if it's not going to stick around then you might as well keep it an iterator
<RX14> wait can you do reverse_each on an iterator, probably not
<RX14> yeah that was stupid
<FromGitter> <bigDaddyS1oth> Just got here, what's someone trying to iterate over?
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
<FromGitter> <bew> @bigDaddyS1oth it was oprypin (sorry for mention), quoting him: now i want a neat way to find every index in an array for which some condition is true
<oprypin> that was 2 different things. anyway, can't you see chat log in gitter?
snsei has joined #crystal-lang
<FromGitter> <bigDaddyS1oth> Can't you check if an array contains certain elements using `.includes?`or is `.includes?` apart of `String`? you could do a while do loop for a range of elements that are included in an array and then do whatever you want if they're included.
<FromGitter> <bigDaddyS1oth> I mean if we had a `foreach` you could do `foreach range_array in arrayToIterate do`
<FromGitter> <akzhan> hello, glad to meet you
<FromGitter> <akzhan> just pushed fix for einpogresss error, it looks like correct
<FromGitter> <bigDaddyS1oth> and then you could do something to do if certain elements in a range aren't included. Like...hmm...but again, we don't have a `foreach` unless `for variable.each`does the same thing.
<FromGitter> <bigDaddyS1oth> The take away from this should be; we need easier ways to iterate over data collections and strings. :P
<FromGitter> <akzhan> Hmm.. `collection.each |item|` looks like short and intuitive. `foreach item in collection` is longer and intuitive too. But newcomers usually know about each.
sz0 has joined #crystal-lang
<FromGitter> <bigDaddyS1oth> True.
<FromGitter> <mverzilli> hey all! we just published the CodeCamp presentations and code examples here:
<FromGitter> <akzhan> @mverzilli nice presentations. can it be rewritten as article (all of them)?
<TheGillies> I saw future/parallel functions in a presentation
<TheGillies> are these in crystal?
<TheGillies> and lazy func
<TheGillies> in the "concurrency and processes" presentation
<FromGitter> <crisward> I'm getting a "Exception: Error writing file: Broken pipe" error when a web socket is closed by browser mid-send from crystal. Any ideas how to handle this? Rescuing this exception doesn't seem to work?
<FromGitter> <akzhan> you should ignore SIGPIPE, i suppose
<FromGitter> <mverzilli> @akzhan that would be great
<FromGitter> <mverzilli> I guess with time we could do that (or add it to the language reference)
<FromGitter> <crisward> @akzhan How do I do that ?
<FromGitter> <akzhan> Yes, I was wondering, but noy found these keywords in current codebase. looks like not published yet.
<FromGitter> <bew> @mverzilli awesome, thanks for the presentations!
<FromGitter> <mverzilli> <TheGillies> `parallel` and `lazy` are macros, so you can find them at the top level docs:
<FromGitter> <akzhan> Wow!
<FromGitter> <mverzilli> we need to enhance that, it's super difficult to find stuff that's at the top level
<TheGillies> mverzilli: many thanks
<FromGitter> <mverzilli> you're welcome!
<FromGitter> <akzhan> @crisward I doesn’t know Crystal well, but looks like you need to ⏎ ⏎ ```require «signal» ⏎ ⏎ Signal.trap(Signal.PIPE, Signal.ignore)``` []
<FromGitter> <crisward> @akzhan thanks! - I found an example in this test
<FromGitter> <akzhan> This is usually required for daemon processes.
<FromGitter> <crisward> I'll give it a go
<FromGitter> <johnjansen> @oprypin you can also do this style of thing
<FromGitter> <bararchy> ```Signal::PIPE.trap do ⏎ puts "doing something" ⏎ end ⏎ ``` []
<TheGillies> "Conditionally spawns a Fiber to run &block in the background. " why do code examples use a spawn to call lazy result then?
<TheGillies> also not really sure what the difference between lazy and future is. does future run the block at runtime whereas lazy waits for explicit .get call?
<FromGitter> <crisward> @bararchy used that to wrap my socket.send - seems to have worked a treat. Thanks @bararchy @akzhan !
<FromGitter> <bararchy> @crisward Enjoy :)
<TheGillies> answered my own question re: future/lazy, future block does execute at runtime
snsei has quit [Remote host closed the connection]
<FromGitter> <akzhan> lazy doesn’t run block immediately. Src/
<TheGillies> lazy doesn't look like it runs in background, am I missing something?
<TheGillies> is it essentially just a memoization feature?
<FromGitter> <akzhan> <TheGillies> I have seen `lazy` just a minutes ago, so also in expirements :)
<FromGitter> <akzhan> Lazy spec is old as two years ago
<FromGitter> <akzhan> Documentation must be updated, but examples needed for start
<RX14> @mverzilli thanks for the compiler internals slides, especially the ones on the semantic phases
<RX14> would love to see some kind of intro to compiler work
<RX14> lazy/future/parallel are cool but noone knows they exist
<FromGitter> <mverzilli> @RX14 :). some kind of intro? would you ellaborate?
<FromGitter> <mverzilli> <TheGillies> `lazy` only spawns if you call `get`
<RX14> some kind of blog post or something to help people who want to contribute to the compiler get started
<FromGitter> <mverzilli> `future` attempts to spawn immediately
<RX14> like this slideshow but more in depth
<FromGitter> <akzhan> @mverzilli I can help with documentation on concurency macros in the Language reference, but need examples of code. ⏎ ⏎ Agrhhh, I have used Crystal without great macros.
<RX14> would take quite a bit of effort though
<RX14> and would be best as a living document not a blog post
<FromGitter> <mverzilli> yes, this is a start
<FromGitter> <mverzilli> agree
<FromGitter> <akzhan> just mention that Crystal already used by myself in production. :) I’m novice, start learning at 1 May.
<RX14> @akzhan you already seem to be doing great
<FromGitter> <mverzilli> <Gillies> memoization isn't the central concept here. in that regard `future` and `lazy` are actually the same: no matter how many times you call `get`, the block only executes once
<FromGitter> <bew> @mverzilli about the presentations in the archive (of the code camp), I've inserted number prefixes, to have them in order, would you mind to change that in the official zip?
balduin has quit [Remote host closed the connection]
<FromGitter> <mverzilli> @bew not sure what you mean. you sorted them? shoot me an email to and I'll take a look
<TheGillies> mverzilli: both lazy/future docs say they run "in the background in a fiber" yet they are blocking. that's what I'm not getting
<RX14> the get call is blocking
<RX14> the future{}/lazy{} block is not
<TheGillies> ah
<TheGillies> I get it now
<FromGitter> <mverzilli> that
<TheGillies> makes sense, thanks
<RX14> also .get isn't blocking if it finishes before you call it obviously
<TheGillies> well get will always be blocking on lazy right because it doesn't execute until you call it?
<RX14> the first time, yes
<RX14> but the second time it won't be
<TheGillies> first time is the best time
<TheGillies> ok
<TheGillies> thanks
<FromGitter> <mverzilli> I think the docs on that are not very helpful, that's the root problem :P
<FromGitter> <bew> @mverzilli I meant:
<RX14> it doesn't have docs afaik
<RX14> it's marked :nodoc:
<FromGitter> <bew> (not sure if it's the correct order)
<RX14> as there was discussion of removing or revamping future
<RX14> it looks a bit messy to me
<FromGitter> <mverzilli> I mean this:
<RX14> ah
<RX14> documenting and cleaning up future would be great
<TheGillies> it's obvious when you realize it's talking about lazy/future call and not the get call heh
<FromGitter> <mverzilli> @bew, that's cool we'll do it
<FromGitter> <mverzilli> thanks for clarifying
<RX14> might be worth reducing it's size by using a union for the type i'm not sure
<FromGitter> <bew> You're welcome ;)
<TheGillies> If you just remove "Conditionally spawns a Fiber to run &block in the background" from lazy func would make sense again
<TheGillies> that's the confusing bit, since nothing happens initially
<FromGitter> <mverzilli> Yeah, I have no idea what that means tbh :P
<TheGillies> I was probably copy pasted from future
<TheGillies> since it's the same text and makes sense there
<TheGillies> it was*
<RX14> @mverzilli wtat do you think about moving Future to the top level and documenting it
<RX14> should it really be in Concurrent?
<FromGitter> <mverzilli> do you mean Future, the class?
<RX14> yes
<FromGitter> <johnjansen> i was just about to say that `Concurrent::Future` needs some docs ;-)
<RX14> seems inconsistent for it to not be top-level to me
<RX14> and for it to be :nodoc:
<FromGitter> <akzhan> Some macros MUST be documented as language topics itself. Just by macros chapter. It’s contrlogically but dramatically reduces learning curve.
<FromGitter> <mverzilli> yeah, last we talked about it was kind of intentionally under documented because we wanted to review the design
<RX14> @mverzilli yeah that would be nice too
<RX14> looking back it looks like the API of it is fine
<FromGitter> <johnjansen> @RX14 i think that `lazy` and `future` are nice helpers at the top level, its ok for the classes to be where they are
<RX14> but people using the helpers need to nkow about the class
<FromGitter> <mverzilli> but maybe it's not the best approach, let me check with Waj what he has in mind in the long term
<RX14> @mverzilli sure
<FromGitter> <johnjansen> totally need the class documented … for sure
<FromGitter> <akzhan> Just document it in the language, not sodlib. as examples, may be.
<FromGitter> <akzhan> With references to stdlib.
<RX14> @akzhan I think there is a need for a guided tour of the API docs
<FromGitter> <akzhan> Yep
<FromGitter> <mverzilli> yeah there's a place for something that bridges the language reference with the API docs
<RX14> a topic-based grouping of important classes
<RX14> so basics with array, hash, string etc
<RX14> with links to the API docs
<RX14> an into chapter with gotchas about the API docs
<RX14> namely the top level namespace and object classes everyone misses
<RX14> and pointing out that a lot of the methods on collections are in enumerable/indexable
<FromGitter> <mverzilli> always reminds me of this:
<RX14> yeah lol
<oprypin> python does that very well
<oprypin> but it's an entirely different mentality for documentation
<oprypin> they have a much more advanced system and almost never just plop functions and their generated docs
<FromGitter> <akzhan> <oprypin> nothing stops us to use good documentation practices. You may offer some topics layout, for example.
<oprypin> it's too much work though to get to that result
<RX14> too much work for a growing language maybe, but we should make it possible
<RX14> we should create the tools and start the seed so that things can be added
<FromGitter> <akzhan> Just provide good examples with minimum adoption. I like to dicument anything, maybe here too.
<RX14> there's pretty good examples for a lot of the stuff
<RX14> especially array/hash/enumerable
<FromGitter> <akzhan> There?
<oprypin> autogenerated documentation can never beat this
<oprypin> and python does indeed show a perfect example of tying together the tutorial and API docs but it's more on the API docs being readable doocuments in their own right now just an alphabetically sorted list
<oprypin> not* just
<RX14> oprypin, that is autogenerated documentation, the main differences to crystal I see is that the "header" docs are way way larger
<RX14> and that methods are ordered explicitly
<FromGitter> <akzhan> Yes, Crystal documentation is too divided to language/stdlib and have no bridges between. But it’s simply curent state. It will be reworked.
<RX14> and each section of class/instance methods has it's own heading and custom intro
<RX14> oh and examples at the bottom
<RX14> it's not *too much work*
<oprypin> oh and this and that
<RX14> to move crystal's docs to be something like that
<RX14> it can be done incrementally
Ven has joined #crystal-lang
<oprypin> one thing's for sure - alphabetic sorting has to go
Ven is now known as Guest63831
<FromGitter> <akzhan> btw I have requested pull for .editorconfig in crystal init. This is widely used so good to merge #4422
<DeBot> (Add .editorconfig template on crystal init command.)
marius has quit [Quit: leaving]
<oprypin> no idea what that thing does but whatever, `init` is bloat anyway
<oprypin> in my view the solution to boilerplate is not automating its creation but removing it
<RX14> ideally but it's not always possible
<RX14> i could bootstrap a project without the template easilly
Guest63831 has quit [Ping timeout: 240 seconds]
<FromGitter> <akzhan> It’s simple. my team use VSCode, Sublime, Vim and Emacs. ⏎ ⏎ We need common divider, and does it. Just like crystal tool format.
<RX14> however a newcomer wants that framework
<RX14> and wants to know the standard
<FromGitter> <akzhan> Crystal team already use it.
<oprypin> editorconfig is a good initiative
Ven_ has joined #crystal-lang
Ven_ has quit [Client Quit]
TheLemonMan has joined #crystal-lang
<FromGitter> <akzhan> @RX14 i just comment your Pull request, I suppose we need any benchmark tool that shows changes before/after the change. #4428
<DeBot> (Add limits to HTTP request parsing)
<FromGitter> <akzhan> And results should be added to PR (may be automatically)
<RX14> I don't think that a benchmark should be required unless automated
<FromGitter> <akzhan> Yep. just like coverage.
<RX14> yeah i'll put that on my "CI plans" list :)
<RX14> but i can do one one-off for here
<RX14> the gets calls shouldn't have much of an impact at all
<FromGitter> <akzhan> Practice shows that almost always can not measure speculative conclusions
<FromGitter> <akzhan> Sorry for my English, I have no practice for years :)
<RX14> no it's pretty good, I can always understand you
<TheGillies> ĉu vi povas paroli esperanton? :P
<FromGitter> <akzhan> So benchmarks have a best fit here.
<FromGitter> <akzhan> Ne, bedaŭrinde
<TheGillies> sed... vi ĵus parolis ĝin :P
<FromGitter> <akzhan> What can not you learn by walking with Russian bears in Moscow.
<TheGillies> ?
<FromGitter> <akzhan> it’s just google translate :)
<FromGitter> <akzhan> I’m from Moscow, Russia.
Raimondi has quit [Quit: WeeChat 1.8-dev]
* TheGillies is from Portlandia
<FromGitter> <akzhan> Glad to see ya
<FromGitter> <akzhan> but it is tv series isn’t it?
<FromGitter> <akzhan> Sorry it’s offtopic
<TheGillies> TV series is about a real place
<FromGitter> <akzhan> Oops Portland :)
sz0 has quit [Quit: Connection closed for inactivity]
Raimondi has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest58788
Guest58788 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven_ has joined #crystal-lang
yogg-saron has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven_ has joined #crystal-lang
pduncan has quit [Ping timeout: 255 seconds]
<crystal-gh> [crystal] spalladino pushed 1 new commit to master:
<crystal-gh> crystal/master be945b5 Chris Hobbs: Added compile progress tracker (#4182)...
<FromGitter> <TheLonelyGhost> Very much late to the party, but I'm also very interested in docs for the compiler. Also thought a living doc would be a good medium. Is a newbie (to lower-level programming) needed to help with it? I just need to pair with a more advanced person who has worked on the compiler to write something up.
* FromGitter * TheLonelyGhost volunteers as tribute
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
zipR4ND1 has joined #crystal-lang
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zipR4ND has quit [Ping timeout: 240 seconds]
bjz has joined #crystal-lang
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest72935
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<TheGillies> When I try and do `{% for url in urls %}` I get `for expression must be an array, hash or tuple literal, not Var:`
<TheGillies> is there a way to iterate over vars in macros?
<FromGitter> <fridgerator> is it a macro var?
<FromGitter> <johnjansen> what is `urls`?
<TheGillies> it's an array of urls
<TheGillies> pass as arg to macro
<FromGitter> <johnjansen> might help to share a little more code
<FromGitter> <fridgerator> you cant reference non macro vars in side of a macro
<FromGitter> <johnjansen> and yeah … what he said
<TheGillies> that's essentially what im trying to do
<FromGitter> <johnjansen> urls is not a macro var
<TheGillies> yeah
<TheGillies> i figured
<TheGillies> doesn't really help me tho heh
<FromGitter> <johnjansen> remember macros are expanded at compile time, vars are run time
<TheGillies> Is it because of the splat?
<FromGitter> <johnjansen> in that case jobs is a macro var
<TheGillies> why is mine not a macro var and that one is?
<RX14> TheGillies, urls is a macro var inside the macro
Guest72935 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<RX14> however when you pass in the urls variable when you call the macro, that's a variable AST node
Ven has joined #crystal-lang
Ven is now known as Guest39520
<RX14> there's not much you can do with just a variable name
<TheGillies> Ok got it
<RX14> so you'd have to pass the %w{} literal directly in the macrop
<TheGillies> Makes sense
<TheGillies> Thanks
<RX14> so this expands correctly
<RX14> although I hope that example isn't the final code, it's much easier to do without a macro
<FromGitter> <johnjansen> sorry had to race out to pick up the little boy… and @RX14 has summed it up nicely
<FromGitter> <johnjansen> you could of course define `urls` as `URLS` instead … if thats what you really want
<FromGitter> <johnjansen> @TheGillies did you have a read of this (im assuming so)
Guest39520 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<TheGillies> Is there way to convert a var to a literal so I can use it in a macro?
<Papierkorb> TheGillies: no, a variable is *variable* in its value, you'd need a time machine to predict its value at compile time when the macro is evaluated
<Papierkorb> TheGillies: You can access constants though
<TheGillies> RX14: I'm messing around with parallel so I don't want to execute code beforehand that's why I'm using a macro
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> what?
<TheGillies> parallel(, Foo.baz) is there a way to pass in an arg to parallel macro or do I need actual AST?
<TheGillies> My problem is I don't know how many things I'm going to insert into parallel
Ven_ has joined #crystal-lang
<RX14> I wish parallel was just a normal method
<RX14> it should be in all honesty
<RX14> i feel like it's possible
<TheGillies> but that code paste still needs to know number of urls beforehand
<FromGitter> <akzhan> is macro is definition like C preprocessor but AST level?
<Papierkorb> akzhan, something like that
<FromGitter> <akzhan> frm that point macro just transforms AST tree
<FromGitter> <akzhan> Soory but I’m newbee to Crystal so it’s my prediction
<RX14> macros take an AST as input and produce text as output (which is instantly parsed back into an AST)
<TheGillies> i guess since parallel is a macro and macros happen at compile time there is no way to do parallel against unknown urls
<RX14> so it's pretty much like an ASt transform
<RX14> however it does that by templating text which makes it a bit easier to use
<FromGitter> <akzhan> We need the hero.. hmm.. something like preprocessor output shower
<RX14> there's a `crystal tool expand` which should expand macros at a place
<FromGitter> <akzhan> Thanks @RX14. Just fit, but not yet inspected by me )
<TheGillies> Are there any mainstream programming languages that don't use english for the keywords, etc?
<Papierkorb> Do excel expressions count?
<TheGillies> seems like english really is the hegemony there heh
<FromGitter> <akzhan> None.
<FromGitter> <johnjansen> @papierkorb #excel hahaha :-)
<FromGitter> <akzhan> Yes, English is common modulo
<Papierkorb> there were a few tries to create a multi-"lingual" language, but all failed as far mainstream goes. it just greatly reduces interop. It only works, and even then only to an extent, if you have a really limited scope, and want to enable non-programmers to program. Like .. Excel.
<Papierkorb> I don't even know if I could open an english excel sheet, if it would translate the function names into German for me, or if it would blow up or whatever
<FromGitter> <akzhan> In Russia there are several programming languages based on Cyrillic, but nobody uses them outside the exUSSR, which is predictable
<TheGillies> It's rather ironic since a lot of mainstream languages don't have english speaking authors
<Papierkorb> Code comments are a different matter though
<FromGitter> <akzhan> Ruby yeah :)
<FromGitter> <johnjansen> @TheGillies did you read the code for #parallel
<TheGillies> johnjansen
<TheGillies> er johnjansen: yes
<FromGitter> <johnjansen> ok cool
<TheGillies> Tempted to just rewrite my own parallel as a function
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <johnjansen> a function is easy to achieve
<FromGitter> <johnjansen> a macro happens at the wrong time for your use case (i believe)
<Papierkorb> I .. don't even know what parallel is good for
<FromGitter> <akzhan> use Future, Luck
<FromGitter> <johnjansen> we talked about it at code camp, but i cant remember what we decided
<FromGitter> <johnjansen> the notes might cover it
snsei has joined #crystal-lang
<TheGillies> parallel is a good help for when you want to do like 50.times{do thing} 50.times{receive thing}
<FromGitter> <johnjansen> hmmm only if you know you have 50 things at compile time
<TheGillies> Yeah that's the problem
<TheGillies> I think it's a macro because it lets you put in raw code, which I guess it helpful but then it's a tradeoff
<FromGitter> <johnjansen> moreover its good for `my program has 4 parallel processes, that stand through the life of the app`
<FromGitter> <johnjansen> its really just a matter of boiler plate code for something that should be backgrounded
<TheGillies> yeah
<TheGillies> that's what I was thinking
<TheGillies> it's a generic background boiler plate macro
<FromGitter> <johnjansen> yes
<TheGillies> for things you know at compile time :P
Ven_ has joined #crystal-lang
<FromGitter> <johnjansen> you probably should look at the expanded macro, which you can do by adding {{debug}} at the end of a copy of the macro
<TheGillies> what does "end of a copy of macro mean"
<TheGillies> like copy and paste then edit?
<FromGitter> <johnjansen> copy the macro code, and insert {{debug}} at the end of the macro method
<TheGillies> ok
snsei has quit [Ping timeout: 268 seconds]
<TheGillies> undefined macro variable 'debug'
<FromGitter> <johnjansen> oops {{debug()}}
<FromGitter> <johnjansen> sorry
<FromGitter> <johnjansen> give your new macro a new name (like parallel_2) ;-)
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Philpax has joined #crystal-lang
<TheGillies> This ended up being way more terse heh
<FromGitter> <johnjansen> well yes
<FromGitter> <johnjansen> and not compile time
<FromGitter> <akzhan> use at runtime ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I suppose []
Ven has joined #crystal-lang
Ven has quit [Client Quit]
<FromGitter> <akzhan> I didn’t test it
<FromGitter> <johnjansen> same thing in the end
<FromGitter> <akzhan> you about wait all responses? i’m lazy to write
<FromGitter> <akzhan> Basics
<FromGitter> <johnjansen> @akzhan it literally results in the same code … `future` is a macro as follows
<FromGitter> <johnjansen> which tips out exactly what you typed ;-)
<FromGitter> <akzhan> Yes, of course ) it’s just extend )
<FromGitter> <akzhan> i’m unsure that vars got (urls) through macro, but idea and implemented. are same
<FromGitter> <akzhan> Just because I’m newbee and not yet jnow macros, but actively look into compiler/stdlib sources
<FromGitter> <johnjansen> macros replace (in place) code with boilerplate (pre-compilation) … hence, you cant use var values in macros (constants excluded) but the mentions of macros are preserved as per the template code
<FromGitter> <johnjansen> actually, wait … i retract all that, `future` is a method, not a macro
<FromGitter> <johnjansen> takes a block, instantiates and returns a future
<FromGitter> <johnjansen> that executes said block
<FromGitter> <akzhan> I’m dummy :))) ⏎ ⏎ ```def future(&exp : -> _) ⏎ &exp ⏎ end``` []
<FromGitter> <johnjansen> haha, no i am … but its beer-oclock, so i excuse myself
<FromGitter> <akzhan> i’m too :beers:
<FromGitter> <akzhan> it cannor be played I think. ⏎ ⏎ lets try to upsert require "http/client"
<FromGitter> <akzhan> So did it locally
<TheGillies> you can't require http in playground
<FromGitter> <johnjansen> yeah, use local … playground + http == ssl issue
<FromGitter> <akzhan> So you can’t use http client in playground
<FromGitter> <johnjansen> locally but not at
muhlisbc has joined #crystal-lang