[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
mame@ruby-lang.org wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <normalperson@yhbt.net> wrote:
[ruby-core:82479] [Ruby trunk Feature#13839] String Interpolation Statements
From:
shevegen@...
Date:
2017-08-26 07:23:03 UTC
List:
ruby-core #82479
Issue #13839 has been updated by shevegen (Robert A. Heiler).
> I was listening a talk by Rasmus Lerdorf, the creator of PHP.
> He said that one of the most appealing feature he added to
> PHP was to include trivial templating out of the box.
I do not think that templating was the killer feature of PHP.
I have not systematically analyzed the codebase of phpBB, mediawiki,
drupal or wordpress but I doubt that templating played a huge
role in any of these codebases.
> in Ruby or Python, it's harder to get started, you have to
> require an external library and you are overwhelmed by all
> these competing choice
I somewhat agree with you here in the sense that inclusion into
stdlib is a good thing in general. That does not necessarily
mean that I agree with you specifically here in this example,
but in general, I concur there. I think that PHP has got only
one thing right and that was a focus on the www. I'd wish ruby
would have a similar focus on the www too. And I don't mean
external code bases such as rails; I really mean integral to
ruby itself.
> But I don't know really how you guys feel about that, I am
> not a language designer. :)
Ultimately you don't really need to care about everyone -
you only have to convince matz. :)
I mean, of course it would be better if you can convince others
in the ruby core team too, but ruby is matz's language and
he is the main designer.
> I'm not a language designer too and probably this is Matz
> matter, but my personal feeling is that PHP's syntax is
> originally kind of template but Ruby is not.
I agree here with Takashi Kokubun; PHP had a different origin
and a different focus. Ruby has the better and more consistent
design everywhere in my experience.
On a general side note, no matter in this proposal but also not
with ERB or erubi or anything else - I always feel that all
those templating solutions are extremely ugly. I dislike all
of them. :)
That actually does not mean that I am against them per se, mind
you; I think it's perfectly fine that the FUNCTIONALITY is
available, be it in stdlib or in a gem - but from a beauty
aspect ... I really dislike all of them.
> Yes, that's it! :) I just wanted to improve string interpolation
> with %{statement} like syntax - and NOT adding a Template class
> or something like that (this was just a demo implementation in Ruby) :)
I guess it is better because one '%' was eliminated in the process;
I still think that it is ugly, even after the elimination of '%'. :D
In the game wesnoth, they even used a XML variant as a programming
language, called WML; later they also added support for lua.
I have never before seen something as ugly as WML - you essentialy
would use conditional checks in something like [if condition] but
it looked like an abomination of a programming language embedded
into XML.
It is not related to your proposal at all of course but just for
comparison:
https://wiki.wesnoth.org/ReferenceWML
And more imporantly with examples:
https://wiki.wesnoth.org/SyntaxWML
XML-like tags to define variables.
[tag] key=value [/tag]
[parent_tag] key1=value1 [child_tag] key2=value2 [/child_tag][/parent_tag]
Anyway, ERB is already in stdlib so in theory it may be possible to
modify or target the behaviour there. I am sure ERB could allow for
multiple syntax behaviour too. You only have to convince matz in the
end. :)
https://ruby-doc.org/stdlib-2.4.1/libdoc/erb/rdoc/ERB.html
----------------------------------------
Feature #13839: String Interpolation Statements
https://bugs.ruby-lang.org/issues/13839#change-66290
* Author: se8 (S辿bastien Durand)
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Hello!
Here is a KISS implementation of a template engine in Ruby:
~~~ ruby
class Template
attr_reader :input
def initialize(input)
@input = input
end
def output
"output = %\0" + @input.gsub("{%", "\0\n").gsub("%}", "\noutput += %\0") + "\0"
end
def render(binding)
eval(output, binding)
end
end
~~~
Usage:
~~~ text
{% if true %}
Hello #{'World'}
{% end %}
Template.new('...').render(binding)
~~~
It's kind of a hack on top of Ruby string interpolation, so it's hell fast (~4 times faster than ERB).
Could it be a good idea to implement this kind of statements directly in Ruby string interpolation? Maybe a syntax like that:
~~~ text
"%{3.times do}Hello #{'World'}%{end}"
~~~
So Ruby would have a fast minimal native template engine, with #{expressions} and %{statements}:
~~~ text
eval(File.read("..."), binding)
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>