Oliphaunte has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
Doug__ has quit [Ping timeout: 250 seconds]
Oliphaunte has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 244 seconds]
deverly has quit []
triangles has left #crystal-lang ["Leaving"]
trapped has quit [Ping timeout: 246 seconds]
mentero has quit [Quit: Connection closed for inactivity]
Philpax has joined #crystal-lang
Guest85036 has quit [Quit: Guest85036]
jsaak has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
<FromGitter>
<jwoertink> Hey all. Crazy question here, but curious if anyone has done this yet or not...
<FromGitter>
<jwoertink> Would it be possible to take a Rails app, and mount a Kemal app in it similar to how you would mount a Sinatra app?
<FromGitter>
<jwoertink> Obviously you can't just throw crystal code in a `routes.rb` file, but maybe higher up or like a mini rack app that just proxies calls to a kemal app ?
iconoclast has joined #crystal-lang
iconoclast is now known as Guest37007
Guest37007 has quit [Ping timeout: 250 seconds]
kulelu88 has quit [Quit: Leaving]
DeBot has quit [Ping timeout: 264 seconds]
jhass has quit [Ping timeout: 264 seconds]
jhass has joined #crystal-lang
snsei has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
willl has quit [Quit: Connection closed for inactivity]
Oliphaunte has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
ponga has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
<FromGitter>
<phoffer> @jwoertink I would think you’d be able to do that in the nginx config
brunto has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 250 seconds]
mark_66 has joined #crystal-lang
Oliphaunte has joined #crystal-lang
alsm has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 252 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 252 seconds]
pawnbox has joined #crystal-lang
DeBot has joined #crystal-lang
matp has quit [Remote host closed the connection]
akwiatkowski has joined #crystal-lang
Philpax has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 272 seconds]
maxpowa has quit [Ping timeout: 250 seconds]
Philpax has joined #crystal-lang
akwiatkowski has quit [Ping timeout: 244 seconds]
Philpax has quit [Ping timeout: 240 seconds]
matp has joined #crystal-lang
Philpax has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
trapped has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
<FromGitter>
<splattael> The pseudo-method `as` only accepts a constant as a parameter. Is this on purpose or could we make `as` accept vars as well?
<DeBot>
it seems like you are asking for a specific solution to a problem, instead of asking about your problem. This often leads to bad solutions and increases frustration for you and those trying to help you. More: http://meta.stackexchange.com/a/66378
<blassin>
is there a way to splat the array into a Tuple of ints?
ylluminate has joined #crystal-lang
<jhass>
Tuple.from is the way
<blassin>
but without the Int32, Int32, ....
iconoclast has joined #crystal-lang
<RX14>
there is no way
iconoclast is now known as Guest81016
<jhass>
if there was a way we wouldn't have tuple in the first place
<RX14>
because the compiler needs to know the number and types of the typle variables
<RX14>
which it can't do with an array
<RX14>
because it's variable elngth
<blassin>
impossible even with macros?
<RX14>
no, because you can't tell
<RX14>
unless it's directly an array literal
<blassin>
yeah, as in my example
<jhass>
if it is, just write a tuple literal?
<RX14>
yes, you could, but thats kinda dumb when you have a tuple literal
<RX14>
theres no point
<blassin>
typing less? :D
<RX14>
no
<jhass>
{1, 2, 3}
<jhass>
[1, 2, 3]
<RX14>
Tuple.from([1, 2, 3]) is way more than {1, 2, 3}
<jhass>
exact same number of keystrokes
<blassin>
yeah
<Guest81016>
I'm trying to figure out a way to have Crystal pass code to a Ruby interpreter to do things that need to be dynamic. The idea would be to fire up an interpreter in the background that would run as a daemon (to avoid the performance hit of a new one for every new bit of code you pass it)
<RX14>
what do you need to do thats dynamic? of just for fun?
<Guest81016>
I'm trying for a syntax like
Philpax has quit [Ping timeout: 252 seconds]
<Guest81016>
( @RX14 right now it's just an experiment, but I think it could be useful...)
<Guest81016>
```
<jhass>
uh oh
<jhass>
?gist
<DeBot>
jhass: Nothing known about gist.
<jhass>
dman
<jhass>
damn
<Guest81016>
ruby do
<RX14>
gist it not code paste
<Guest81016>
# blah blah blah
<RX14>
please
<Guest81016>
end
<RX14>
gist.github.com
<RX14>
but
<RX14>
that wouldnt work because crystal and ruby have a different syntax
<jhass>
?gist=Use https://gist.github.com to put your codes online, with pretty syntax highlighting, multiple files and the chance to update it with new information!
<DeBot>
jhass: Set gist.
<Guest81016>
okay, I'll use gist, but the intro line said 3 lines or less was okay to paste
<RX14>
the common usage is "code" not "codes" here jhass
<RX14>
just to be pedantic
<jhass>
yes.
<jhass>
:P
<jhass>
the bot is open if it annoys you too much ;)
<RX14>
Guest81016, well we both kinda assumed it would be longer than 3 lines
<jhass>
and if you count ``` it was :P
<RX14>
heh
<jhass>
so yeah, as RX14 said, Crystal doesn't parse Ruby code and Ruby doesn't parse Crystal code
<RX14>
but yes, I don't advide even trying the "ruby { <code> }" syntax because even if it doesn't make sense there will be so much ruby that the lexer can't lex
<RX14>
ruby <<-RUBY is a much better approach
<Guest81016>
@jhass: sorry, I assumed that ``` and SHIFT-ENTER would be supported... I'm spoiled by Slack :p
<RX14>
then ruby_name: crystal_var or just var for passing code in
<Guest81016>
@RX14 yeah, that would be easier, but I'm looking for a way to do the ideal syntax if possible
<Guest81016>
passing a string is obviously much easier to implement
<jhass>
do you follow what we're saying?
kulelu88 has joined #crystal-lang
kulelu88 has quit [Changing host]
kulelu88 has joined #crystal-lang
<RX14>
but you can't do it
<jhass>
do you have a concept of what a parser/lexer is?
<RX14>
thats what we're saying
<RX14>
you can't just treat a block of invalid crystal as ruby
<jhass>
macros allow you to work on the AST, the result of the lexing
<Guest81016>
@jhass I have a *concept* of a parser and lexer, but I've never written one/either
<jhass>
that concept is relevant to your idea, don't ignore it
<Guest81016>
I was thinking that it might be possible for a macro to take everything between `ruby do` and `end` and just turn it into a string
<RX14>
you can turn it into a string, yes
<jhass>
the answer is no and it never will be
<RX14>
but if its invalid crystal, it never get to the macro
<RX14>
to be more clear, if it's invalid crystal syntax
<Guest81016>
because it's impossible for the Crystal parser to just ignore everything between `ruby do` and `end`?
<RX14>
yes
<Guest81016>
ok
<Guest81016>
that's :( but I guess it makes sense
<RX14>
you can create some wacky syntax that's still lexed
<RX14>
but it has to lex
<RX14>
and ruby in it's intirety will not
<RX14>
entirety*
<jhass>
I'm still curious as to what usecases you imagine though
<jhass>
if we're talking snippets of code, all of Ruby's dynamism is only useful in the context of the whole program, not just the snippet
<RX14>
i wonder how hard it would be to implement AFL fuzzer support for crystal
<jhass>
if we're talking bigger programs, you wouldn't want to embed anyway, so a simple wrapper around Process.run to run a ruby file would be enough
<Guest81016>
@jhass one use case I can imagine is moving a Ruby codebase to Crystal, but perhaps your last comment just suggested a better way to handle that
<jhass>
RX14: hah, I bet you'd uncover three dozen compiler bugs :P
<Guest81016>
@jhass: are you suggesting that you've never run into any use cases where dynamism is useful?
<RX14>
by fuzzing the compiler?
<RX14>
or just
<RX14>
implementing fuzzing
<Guest81016>
or just offering to help me find native Crystal solutions to any particular problems I'm actually having right now?
<RX14>
Guest81016, the idea would be that if you really really wanted dynamism you wouldn't "embed" it like this
<RX14>
you would either not use crystal at all or call out to a complete ruby program in a nother file
<jhass>
Guest81016: no, I'm saying that there's no useful dynamism in ruby that doesn't have or can't have an idiomatic Crystal alternative, that doesn't need to affect the global program state in general or the type system in particular of the host program
<Guest81016>
ok
<jhass>
and yeah, we're always happily discussing alternatives here ;)
<Guest81016>
okay—thanks
<Guest81016>
my brain is still wired around Ruby, so it's not always clear to me how to do without all the things I've grown used to
<jhass>
sure, just ask ;)
<Guest81016>
so I'm sure I'll take you up on your offcer of help in the future ;)
<Guest81016>
*offer
<Guest81016>
Okay, actually here's a real use case I just remembered, that contributed to me thinking about how to do this
<Guest81016>
actually, 2 related use cases. One where it would be nice to have dynamism built-into Crystal, and one where it might be enough to have something like `ruby do`
<Guest81016>
1) it would be really nice to have Pry for Crystal. I'm pretty sure that RubyDo wouldn't help, unless you could monkey patch Ruby to behave enough like Crystal that people wouldn't notice the differences. (Probably too hard or impossible.) But if there were a way to somehow build Pry in pure Crystal, it would be awesome.
<RX14>
we have crystal play
<RX14>
which is useful for some of the uses of pry
<RX14>
the usage pf pry where you can drop in as a debugger for normal programs is impossible though
<jhass>
a repl is a lot of work for a language like crystal, it basically requires a second compiler
<Guest81016>
2) The second use case is that I know someone building a shell in Ruby. I really like the design decisions he's making, but I predict he's ultimately going to have performance problems. One solution would be to use Crystal to optimize the slower bits, a little like Ruru uses Rust to optimize slower bits. But I wanted to explore the inverse of that strategy: instead of writing in Ruby and using Crystal when you need to, why not write in Cryst
<Guest81016>
and only use Ruby if you need to.
soveran has joined #crystal-lang
<RX14>
why does a shell need to be written in ruby?
<RX14>
if bash can be written in C
<RX14>
a shell can be written in crystal
<RX14>
it's equally as dynamic
<jhass>
well that plays into what I said earlier
<jhass>
for example you can't just magically call crystal methods dynamically just because you try to do it from ruby
<Guest81016>
RX14: the question "why does a shell need to be written in Ruby" is essentially the same as the question "why does Crystal need to exist?"
<jhass>
and I can't come up with any concrete example where I can see the usefulness
<Guest81016>
he knows Ruby very well, not C, so he's using Ruby
<RX14>
what
<RX14>
oh
<RX14>
well then
<jhass>
so if you have some less vague example... ;)
<RX14>
if he wants to learn crystal then he can
<RX14>
and he doesn't need to use ruby in it
<Guest81016>
I'm not likely to persuade him to learn Crystal—or at least not rewrite the entire thing in Crystal
<RX14>
well then, give up
<Guest81016>
give up on what?
soveran has quit [Ping timeout: 276 seconds]
alsm has quit [Ping timeout: 276 seconds]
<RX14>
him writing it in crystal
<Guest81016>
I think there will be bits that will need to be rewritten, and I'd like to introduce Crystal to make those bits fast