[#37708] [Ruby 1.9 - Bug #4956][Open] [PATCH] string.c (tr_s_bang): fix leak with heap strings — Eric Wong <normalperson@...>
Eric Wong <normalperson@yhbt.net> wrote:
On Wed, Jul 06, 2011 at 04:46:44AM +0900, Eric Wong wrote:
[#37714] test fail test/matrix/test_matrix.rb:321 — KOSAKI Motohiro <kosaki.motohiro@...>
http://59.106.172.211/~chkbuild/ruby-trunk/log/20110701T110101Z.log.html.gz
2011/7/1 KOSAKI Motohiro <kosaki.motohiro@gmail.com>:
Test fixed, thanks (indeed, Matrix#** now implements non integer exponents)=
2011/7/2 Marc-Andre Lafortune <ruby-core-mailing-list@marc-andre.ca>:
[#37724] open-ssl related errors on MacOSX — SASADA Koichi <ko1@...>
Hi,
2011/7/2 SASADA Koichi <ko1@atdot.net>:
2011/7/2 Martin Bo=DFlet <martin.bosslet@googlemail.com>:
[#37730] [Ruby 1.9 - Bug #4962][Open] come back gem_prelude! — Yusuke Endoh <mame@...>
On Sat, Jul 02, 2011 at 02:18:35PM +0900, Yusuke Endoh wrote:
[#37757] [Ruby 1.9 - Bug #4969][Open] Subtle issue with require — Thomas Sawyer <transfire@...>
[#37761] [Ruby 1.9 - Feature #4970][Open] FileUtils refactored — Thomas Sawyer <transfire@...>
[#37805] [Ruby 1.8 - Bug #4979][Open] `require 'foo'` is ambiguous when there is both foo.rb and foo.so — Antonio Terceiro <terceiro@...>
[#37840] [Ruby 1.9 - Feature #4985][Open] Add %S[] support for making a list of symbols — Aaron Patterson <aaron@...>
I guessed that %S(...) is S-expr syntax.
[#37853] [Ruby 1.9 - Bug #4989][Open] Document Socket constants — Eric Hodel <drbrain@...7.net>
Why change all the statuses to low here? I don't see the validity of
Hi
On Fri, Jul 8, 2011 at 08:25, KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:
[#37858] [Ruby 1.9 - Bug #4992][Open] finalizer中のThread.newでSEGV — Shota Fukumori <sorah@...>
> -- Thread.new in finalizer raises SEGV
[#37866] [Backport87 - Feature #4996][Open] About 1.8.7 EOL — Shyouhei Urabe <shyouhei@...>
[#37908] [Ruby 1.9 - Bug #5002][Open] Ripper fails to distinguish local vars from vcalls [PATCH] — Michael Edgar <michael.j.edgar@...>
[#37913] [Ruby 1.9 - Bug #5003][Open] Enumerator#next segfaults in OS X Lion (10.7) — Ganesh Gunasegaran <ganesh.gunas@...>
[#37917] [Ruby 1.9 - Feature #5005][Open] Provide convenient access to original methods — Lazaridis Ilias <ilias@...>
[#37932] [Ruby 1.9 - Feature #5008][Open] Equal rights for Hash (like Array, String, Integer, Float) — Suraj Kurapati <sunaku@...>
On Thu, Mar 29, 2012 at 13:25, rosenfeld (Rodrigo Rosenfeld Rosas) <
[#37936] [Ruby 1.9 - Feature #5010][Open] Add Slop(-like) in stdlib and deprecate current OptionParser API — Rodrigo Rosenfeld Rosas <rr.rosas@...>
Hi,
Em 09-07-2011 20:13, Nobuyoshi Nakada escreveu:
[#37985] [Ruby 1.9 - Bug #2616] unable to trap in doze — Motohiro KOSAKI <kosaki.motohiro@...>
[#37988] [Ruby 1.9 - Feature #5016][Open] Kernel#caller with negative limit should limit result to N initial frames — Nikolai Weibull <now@...>
[#37997] psych and libyaml v0.1.4 testing? — Jon <jon.forums@...>
Anyone run into issues with psych and the latest libyaml patchlevel?
[#38011] [Ruby 1.9 - Bug #5018][Open] ruby_1_9_3 branch is missing from official GitHub mirror — Luis Lavena <luislavena@...>
[#38096] [Ruby 1.9 - Feature #5033][Open] PATCH: 1.9: gc_mark_children: Avoid gc_mark() tail recursion, use goto again. — Kurt Stephens <ks.ruby@...>
[#38109] [Ruby 1.9 - Bug #5034][Open] C Source Code formatting — Lazaridis Ilias <ilias@...>
[#38137] [Ruby 1.9 - Bug #5038][Open] Ruby 1.9.2 stops on some Regular Expressions — Bob Ambartsumov <bob@...>
[#38140] [Ruby 1.9 - Feature #5041][Open] Set FD_CLOEXEC for all fds (except 0, 1, 2) — Akira Tanaka <akr@...>
[#38158] Proposal to merge net2-http for Ruby 1.9.4 — Yehuda Katz <wycats@...>
I gave a talk at Ruby Kaigi about my work on Net::HTTP (
2011/7/18 Yehuda Katz <wycats@gmail.com>:
Yehuda Katz
[#38164] [Ruby 1.9 - Bug #5046][Open] Bug with xmlrpc::client, basic auth and long authentication strings — Herwin Weststrate <herwin@...>
[#38171] [Ruby 1.9 - Bug #5047][Open] Segfault (most likely involving require) — Jack Christensen <jack@...>
Hiroshi Nakamura <nakahiro@gmail.com> wrote:
On Jul 22, 2011, at 2:41 PM, Eric Wong wrote:
Thank you for the trying the patch.
[#38172] [Backport87 - Backport #5048][Open] Make failed on tk bindings under OSX Lion fresh install — "Wayne E. Seguin" <wayneeseguin@...>
[#38182] [Ruby 1.9 - Feature #5054][Open] Compress a sequence of ends — ANDO Yasushi ANDO <andyjpn@...>
[#38197] [Ruby 1.9 - Feature #5056][Open] About 1.9 EOL — Shyouhei Urabe <shyouhei@...>
Hello,
Hi,
Hi,
On 23/08/11 at 06:50 +0900, SASADA Koichi wrote:
(2011/08/23 20:09), Lucas Nussbaum wrote:
On 23/08/11 at 20:20 +0900, NARUSE, Yui wrote:
[#38295] [Ruby 1.9 - Feature #5064][Open] HTTP user-agent class — Eric Hodel <drbrain@...7.net>
[#38343] [Ruby 1.9 - Bug #5068][Open] Issue with "duplicated when clause is ignored" — Stefano Mioli <stefano.mioli@...>
[#38367] [Ruby 1.9 - Feature #5072][Open] Avoid inadvertent symbol creation in reflection methods — Jeremy Evans <merch-redmine@...>
[#38391] [Ruby 1.9 - Bug #5076][Open] Mac OS X Lion Support — Yui NARUSE <naruse@...>
[#38451] [Ruby 1.9 - Bug #5090][Open] Segfault using Enumerator — Robert Syme <rob.syme@...>
[#38464] [Ruby 1.9 - Bug #5091][Open] Can't require './.testrb' — Thomas Sawyer <transfire@...>
[#38491] 1.9.3 Status Update? — Joshua Ballanco <jballanc@...>
Hello ruby-core,
[#38510] [Ruby 1.9 - Feature #5097][Assigned] Supported platforms of Ruby 1.9.3 — Yui NARUSE <naruse@...>
Yui NARUSE <naruse@airemix.jp> wrote:
On Mon, Jul 25, 2011 at 11:52 PM, Yui NARUSE <naruse@airemix.jp> wrote:
[#38538] [Ruby 1.9 - Feature #5101][Open] allow optional timeout for TCPSocket.new — Eric Wong <normalperson@...>
2011/7/27 Eric Wong <normalperson@yhbt.net>:
Tanaka Akira <akr@fsij.org> wrote:
2011/7/29 Eric Wong <normalperson@yhbt.net>:
2011/7/30 Tanaka Akira <akr@fsij.org>:
[#38610] [Ruby 1.9 - Feature #5120][Open] String#split needs to be logical — Alexey Muranov <muranov@...>
[ruby-core:37941] [Ruby 1.9 - Feature #3845] "in" infix operator
Issue #3845 has been updated by Michael Edgar.
File in.expression.diff added
I personally believe `in` belongs as an operator, it should match natural, mathematical, set-inclusion notation, and it should invoke `include?`.
Many have discussed how it is just as possible to write "does S include x" as well as "is x in S": especially in English, there are many ways of writing things. As there are in Ruby! This should not distract us from why the idea has been proposed in the first place.
In mathematics, we very rarely write "Set S includes x", let alone as a predicate. Instead, we write, (in LaTeX), x \in S. This is because most commonly the focus of this predicate is the element in question: is it in the set or not? This is a property of the set, but the focus of discourse is the (potential) element. The Ruby method belongs on the set, OO-speaking, because it is in charge of the information involved. But it is not unreasonable to note that writing S.includes?(x) introduces a mismatch between how computer scientists typically consider such questions.
Ruby's OO syntax does not naturally allow us to express this "foo in S" idea, in that order, without adding a method to all potential elements. I don't believe introducing a new method, `.in?` is a good idea. There should be no reason to introduce a misleading method name that suggests an element might know what sets it is in. Instead, I think that introducing `in` as an syntactic construct (much like for loop syntax) is appropriate. Since Ruby already has an idiomatic inclusion method name, `include?`, I believe it should invoke that, right to left (`foo in bar` means `bar.include?(foo)`). Here, the parallel with for loop syntax becomes more clear.
For loops address the same concern: it makes sense to write, in English, "array, each of your elements, x, should do this" just as it makes sense to say "for each x in the array, do this". OO-style invocation supports the former, but not the latter, and so we have a syntax which reverses the order: in for loops, the receiver comes after the variable names it uses. This supports a different, natural way to describe loops. Just like `in`, it works by using a convention-based method name. For loops in Ruby are maligned primarily due to potentially-surprising scoping issues, but their syntax itself is subjectively attractive.
I have attached a patch which incorporates this approach. It includes the appropriate ripper event(s).
----------------------------------------
Feature #3845: "in" infix operator
http://redmine.ruby-lang.org/issues/3845
Author: Yusuke Endoh
Status: Assigned
Priority: Normal
Assignee: Yukihiro Matsumoto
Category:
Target version:
=begin
Hi,
I'd propose "in" infix operator.
(<arg> in <args>) yields true when <arg> is included in <arg>.
Otherwise it yields false.
p "found" if 1 in 1, 2, 3 #=> found
p "not found" if 0 in 1, 2, 3 #=> not found
"in" operator is clearer to the reader than Array#include?:
p "found" if [1, 2, 3].include?(1)
p "not found" if [1, 2, 3].include?(0)
This proposal is similar to Object#in? proposed in [ruby-core:23543].
But there are two differences:
- "in" operator does not pollute name space of Object class
- each candidate of "in" is evaluated lazily; for example,
1 in 1, 2, foo()
does not call the method "foo" because 1 is found before that.
Note that this proposal ensures the syntax compatibility, since
"in" is already a keyword for "for" statement. But "for" statement
is rarely used. This proposal utilizes the rarely-used keyword.
I wrote an experimental patch. It implements the operator as a
syntactic sugar to "case" statement:
<arg> in <args>
=> (case <arg>; when <args>; true; else false; end)
The patch causes no parser conflict.
One more thing. The following expression is rejected:
foo(x in 1, 2, 3)
This is because it is ambiguous; this expression can be interpreted
as three ways:
foo((x in 1), 2, 3)
foo((x in 1, 2), 3)
foo((x in 1, 2, 3))
You need write parentheses explicitly.
What do you think?
diff --git a/parse.y b/parse.y
index e085088..64318bd 100644
--- a/parse.y
+++ b/parse.y
@@ -745,6 +745,7 @@ static void token_info_pop(struct parser_params*, const char *token);
%nonassoc modifier_if modifier_unless modifier_while modifier_until
%left keyword_or keyword_and
%right keyword_not
+%nonassoc keyword_in
%nonassoc keyword_defined
%right '=' tOP_ASGN
%left modifier_rescue
@@ -1258,6 +1259,14 @@ expr : command_call
$$ = dispatch2(unary, ripper_id2sym('!'), $2);
%*/
}
+ | expr keyword_in args
+ {
+ /*%%%*/
+ $$ = NEW_CASE($1, NEW_WHEN($3, NEW_TRUE(), NEW_FALSE()));
+ /*%
+ $$ = dispatch2(in, $1, $3);
+ %*/
+ }
| arg
;
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 5d76941..6005457 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -1107,4 +1107,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
parse('/', :compile_error) {|msg| compile_error = msg}
assert_equal("unterminated regexp meets end of file", compile_error)
end
+
+ def test_in
+ assert_equal("[in(1,[1,2,3])]", parse('1 in 1, 2, 3'))
+ end
end if ripper_test
--
Yusuke Endoh <mame@tsg.ne.jp>
=end
--
http://redmine.ruby-lang.org