From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id DCD0D19C0029 for ; Fri, 6 Nov 2015 10:21:27 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id DEEA5B5D911 for ; Fri, 6 Nov 2015 10:50:29 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 149EC18CC7FB for ; Fri, 6 Nov 2015 10:50:29 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5BDD812050E; Fri, 6 Nov 2015 10:50:28 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1D1F1120462 for ; Fri, 6 Nov 2015 10:50:24 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=D4qVbyhjZSZV6GvVJy2SpC3akLM=; b=cwN4OyC/DfcLuCSDeT a88zZhrhFXmEiphGdkxtW0jrGXxFQP5lCIQJn/uXnIl7+t166JEsnVj/mIYn5lfq xJxgaBlKXYP3tFYXtcDsLdMfHQgrMSZQPRjE5jqj1EUsf6cVVgL9xZrGZ+1089YE CIWCp6ijbsq0hqISBJnT2OvNI= Received: by filter-151.sjc1.sendgrid.net with SMTP id filter-151.8023.563C075EC 2015-11-06 01:50:22.170990873 +0000 UTC Received: from herokuapp.com (ec2-54-82-110-109.compute-1.amazonaws.com [54.82.110.109]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id msEi8W8RTEaDDK112gH5qQ for ; Fri, 06 Nov 2015 01:50:22.159 +0000 (UTC) Date: Fri, 06 Nov 2015 01:50:22 +0000 From: tom.enebo@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46005 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11537 X-Redmine-Issue-Author: hsbt X-Redmine-Issue-Assignee: matz X-Redmine-Sender: enebo X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4p3R8j+suAhVgEp1FRAijBUG2kl55NLFASPJ HNF8ZPgJ2cYQlf13wYFgV+4eve9rQGwjWYI4QA0iDCpzB56rojsqDvx3uveV7nMMfo47hOpNecMzdN TwAXHoO6m9nlX18= X-ML-Name: ruby-core X-Mail-Count: 71364 Subject: [ruby-core:71364] [Ruby trunk - Feature #11537] Introduce "Safe navigation operator" X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11537 has been updated by Thomas Enebo. Eric Wong wrote: > tom.enebo@gmail.com wrote: > > How about '\'? We can pay homage to Windows file delimeter? > > > > a\b\c > > > > I just scanned lexer and I cannot think of a reason off the top of my head why not...what does \ mean? who knows...what for .? mean? I don't know that either. This suggestion is twice as efficient though since it only uses one character. > > It's already used for continuing long lines. well it is but that is not really an issue since it only will acknowledge '\' if right before end of line (lexer just says spaceSeen and loops back up to top of lexer for its next token). What is really weird to me is if it isn't at the end of the line it returns as the token '\\'. I see nowhere in the grammar where ruby acknowledges this as a valid token. Any other literal escaping happens within lexing. Did I just find a vestigial organ or am I missing something simple? In any case it looks like Matz might have picked something other than .?, which was main reason I came up with \ as an idea (I feel reversing order from other languages will confuse them more than it will help -- so pick something different altogether). -Tom ---------------------------------------- Feature #11537: Introduce "Safe navigation operator" https://bugs.ruby-lang.org/issues/11537#change-54732 * Author: Hiroshi SHIBATA * Status: Closed * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- I sometimes write following code with rails application: ```ruby u = User.find(id) if u && u.profile && u.profile.thumbnails && u.profiles.thumbnails.large ... ``` or ```ruby # Use ActiveSupport if u.try!(:profile).try!(:thumbnails).try!(:large) ... ``` I hope to write shortly above code. Groovy has above operator named "Safe navigation operator" with "`?.`" syntax. Ruby can't use "`?.`" operator. Can we use "`.?`" syntax. like this: ```ruby u = User.find(id) u.?profile.?thumbnails.?large ``` Matz. How do you think about this? -- https://bugs.ruby-lang.org/