Feature #4985
closedAdd %S[] support for making a list of symbols
Added by tenderlovemaking (Aaron Patterson) over 13 years ago. Updated over 12 years ago.
Description
I would like to add %S, which would create a list of symbols.
For example:
%S[foo bar] # => [:foo, :bar]
I've attached a patch which implements this along with ripper events and tests. Thanks to Josh Susser for thinking of this. :-)
Files
qsymbols.patch (5.82 KB) qsymbols.patch | symbol patch | tenderlovemaking (Aaron Patterson), 07/07/2011 01:00 PM | |
qsymbols.patch (5.76 KB) qsymbols.patch | correctly indented patch | tenderlovemaking (Aaron Patterson), 07/07/2011 01:02 PM | |
percent_i.patch (7.2 KB) percent_i.patch | percent i and percent I | tenderlovemaking (Aaron Patterson), 08/04/2011 09:26 AM | |
feature4985.pdf (261 KB) feature4985.pdf | tenderlovemaking (Aaron Patterson), 07/01/2012 04:27 AM | ||
noname (500 Bytes) noname | Anonymous, 07/02/2012 11:29 PM | ||
noname (500 Bytes) noname | Anonymous, 07/02/2012 11:29 PM | ||
4985.patch (7.69 KB) 4985.patch | updated patch to fix conflicts and tests | tenderlovemaking (Aaron Patterson), 07/24/2012 08:44 AM |
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
- File qsymbols.patch qsymbols.patch added
Adding a new patch with correct indentation for parse.y
Updated by vjoel (Joel VanderWerf) over 13 years ago
Wondering idly if the following could be parsed...
:[foo bar]
Eh, maybe it's too inconsistent with % notation anyway.
Updated by matz (Yukihiro Matsumoto) over 13 years ago
Interesting idea (include Joel's)! But I am not sure whether they are the right prefix.
matz.
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Hi,
At Thu, 7 Jul 2011 16:15:36 +0900,
Joel VanderWerf wrote in [ruby-core:37843]:
Wondering idly if the following could be parsed...
:[foo bar]
It would be possible, but conflicts with :[] ("[]".to_sym).
--
Nobu Nakada
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
On Thu, Jul 07, 2011 at 04:48:51PM +0900, Yukihiro Matsumoto wrote:
Issue #4985 has been updated by Yukihiro Matsumoto.
Interesting idea (include Joel's)! But I am not sure whether they are the right prefix.
Ya. We already have %s, so %S might be confusing (especially when
compared to %w and %W). I don't care about the prefix so much as I care
about having the feature. :-)
--
Aaron Patterson
http://tenderlovemaking.com/
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
On Thu, Jul 07, 2011 at 04:48:51PM +0900, Yukihiro Matsumoto wrote:
Issue #4985 has been updated by Yukihiro Matsumoto.
Interesting idea (include Joel's)! But I am not sure whether they are the right prefix.
How about %i and %I? (i stands for "intern").
--
Aaron Patterson
http://tenderlovemaking.com/
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
- File deleted (
noname)
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
- File deleted (
noname)
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) over 13 years ago
How about "%:(symbol1 symbol2)"?
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
Hi,
At Fri, 8 Jul 2011 02:36:50 +0900,
Rodrigo Rosenfeld Rosas wrote in [ruby-core:37850]:
How about "%:(symbol1 symbol2)"?
$ ruby -e 'p %:(:'
"("
Already ":" manages hard works. Don't overload anymore.
--
Nobu Nakada
Updated by tenderlovemaking (Aaron Patterson) over 13 years ago
- File percent_i.patch percent_i.patch added
I've updated my patch to implement %i and %I. They have the same semantics as %w and %W (one with interpolation, one without).
What do you think of this matz?
Updated by tenderlovemaking (Aaron Patterson) about 13 years ago
Bump
Updated by shyouhei (Shyouhei Urabe) over 12 years ago
- Status changed from Open to Assigned
Updated by tenderlovemaking (Aaron Patterson) over 12 years ago
- File feature4985.pdf feature4985.pdf added
adding a slide
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) over 12 years ago
I don't understand why your pdfs have a second weird slide :)
Updated by mame (Yusuke Endoh) over 12 years ago
Received. Thank you!
The second page is mysterious... A cat or something walked a straight line of your keyboard? :-)
--
Yusuke Endoh mame@tsg.ne.jp
Updated by ko1 (Koichi Sasada) over 12 years ago
I guessed that %S(...) is S-expr syntax.
example:
%S((foo bar (baz boo)) #=> [:foo, :bar, [:baz, :boo]]
(I have no idea about use-case of this S-expr literal, except Lisp like DSL)
--
// SASADA Koichi at atdot dot net
Updated by Anonymous over 12 years ago
On Mon, Jul 02, 2012 at 02:17:12AM +0900, mame (Yusuke Endoh) wrote:
Issue #4985 has been updated by mame (Yusuke Endoh).
Received. Thank you!
The second page is mysterious... A cat or something walked a straight line of your keyboard? :-)
Quit likely. Sorry about the second page. ;-)
--
Aaron Patterson
http://tenderlovemaking.com/
Updated by Anonymous over 12 years ago
On Mon, Jul 02, 2012 at 06:45:38AM +0900, SASADA Koichi wrote:
I guessed that %S(...) is S-expr syntax.
example:
%S((foo bar (baz boo)) #=> [:foo, :bar, [:baz, :boo]](I have no idea about use-case of this S-expr literal, except Lisp like DSL)
My patch (and slide) actually uses %i and %I ("i" stands for "intern")
and mirrors %w and %W. %s is already taken :-)
--
Aaron Patterson
http://tenderlovemaking.com/
Updated by claytrump (Clay Trump) over 12 years ago
+1, I'd use that a lot.
Do we need two versions? Why not always interpolate? Can't see who's going
to need a symbol with a litteral #{ or \whatever in it.
This way we could have only %S and it always interpolates.¶
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
=begin
The latest ((%percent_i.patch%)) seems almost fine, except for a conflict in ((%parse.y%)).
=end
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
=begin
Seems like ((%ext/ripper/eventids2.c%)) misses (({tSYMBOLS_BEG})).
=end
Updated by mame (Yusuke Endoh) over 12 years ago
- Assignee changed from matz (Yukihiro Matsumoto) to nobu (Nobuyoshi Nakada)
Aaron Patterson,
I'm happy to inform you that matz has accepted your proposal.
Matz was worried about the letter `i' and searching other ones,
but finally accepted.
Nakada-san,
Could you review the patch attached?
--
Yusuke Endoh mame@tsg.ne.jp
Updated by tenderlovemaking (Aaron Patterson) over 12 years ago
- File 4985.patch 4985.patch added
I've attached an updated patch that includes the correct symbols, fixes the ripper tests, and fixes the conflicts.
Nakada-san: if you're happy with this patch, I can apply. :)
Updated by nobu (Nobuyoshi Nakada) over 12 years ago
Seems fine to me.
Updated by tenderlovemaking (Aaron Patterson) over 12 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r36524.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
-
parse.y: added symbols and qsymbols productions for %i and %I
support. %i{ .. } returns a list of symbols without interpolation,
%I{ .. } returns a list of symbols with interpolation. Thanks to
Josh Susser for inspiration of this feature. [Feature #4985] -
ext/ripper/eventids2.c: added ripper events for %i and %I.
-
test/ripper/test_parser_events.rb: ripper tests
-
test/ripper/test_scanner_events.rb: ditto
-
test/ruby/test_array.rb: test for %i and %I behavior