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 https://github.com/crystal-lang/crystal/issues/4226, 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/unistd.cr`. 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>
<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) https://git.io/vHvDb
yogg-saron has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<bew> about #4430 what are thoses operators?
<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.select -> 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.
<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!
<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/concurrent.future.cr
<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 mverzilli@manas.tech 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
<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
<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
<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 http://editorconfig.org/ 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
<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: https://git.io/vHJks
<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
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.bar, 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
<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…]
<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