ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: atdot <ko1@atdot.net>
To: Ruby developers <ruby-core@ruby-lang.org>
Subject: [ruby-core:96490] Re: [Ruby master Feature#15973] Let Kernel#lambda always return a lambda
Date: Thu, 26 Dec 2019 16:49:02 +0900	[thread overview]
Message-ID: <5C57B954-BC0A-41D4-A647-ABD0B51ACD93@atdot.net> (raw)
In-Reply-To: <redmine.journal-83402.20191225193408.407e43edf48be286@ruby-lang.org>

Ok, make a new ticket about define_method. How about lambda?

Koichi

> 2019/12/26 4:34、zverok.offline@gmail.comのメール:
> 
> Issue #15973 has been updated by zverok (Victor Shepelev).
> 
> 
> Ugh, let me be a bit philosophical here (how many times I promised myself to not engage in discussions about Ruby's "spirit"? I've lost count.)
> 
> I understand the point you are speaking from (language implementer's background, who constantly fights with "dangerously illogical" parts), but for me, one of the key points of Ruby's attractiveness is how far it goes to reduce boilerplate in a logical and humane way. There is a non-neglectible gap between "human" consistency and "computer" (formal) consistency. 
> 
> I am writing in Ruby for >15 years now (and teaching it for >5 years, and blah-blah-blah). I've implemented and used metric shit-ton of DSLs. So, for me and my intuition is experience, it is just this way:
> ```ruby
> skip_if { |user| return 42 }
> ```
> ...is something that will behave "unexpectedly"? Yes. 
> Have I met a lot of cases when it was really written and shot somebody in the head? No.
> What if somebody really happens to meet with this case and is surprised? I believe they'll spend some time to wrap they head about it. That's a price we pay to have "complex language for writing simple code".
> 
> Now, when I see this:
> ```ruby
> def skip_if(&condition)
>  define_method(:skip?, &condition)
> end
> ```
> ...which "should" be "simply workarounded" to this:
> ```ruby
> def skip_if(&condition)
>  define_method(:skip?, -> *args { condition.call(*args) })
> end
> ```
> ...I see it as "your language implementation is really busy doing its important things. So it will not help you to write clean and obvious code. I (language implementation) see what you want to do (define methods implementation from a block in the variable), and I know how to fix it (block should be converted to lambda), but you (puny human) should do it with your own soft hands".
> 
> It _can and will_ harm the will to write simple helping DSLs (which, one may argue, "is a good thing" anyways?..)
> 
> Why, then, bother with "all this proc vs lambda nonsense" (as some may, and do, argue)? All in all, "you don't need this complexity at all", right? Because
> 
> ```ruby
> sources.zip(targets).map { |src, tgt| tgt.write(src) }
> ```
> ...can be "easily workarounded" as this:
> ```ruby
> sources.zip(targets).map(->(arguments) { arguments[1].write(arguments[0]) } }
> ```
> ...and everything suddenly becames more consistent and homogenous...
> 
> We can go this way really far, honestly :)
> 
> ----------------------------------------
> Feature #15973: Let Kernel#lambda always return a lambda
> https://bugs.ruby-lang.org/issues/15973#change-83402
> 
> * Author: alanwu (Alan Wu)
> * Status: Assigned
> * Priority: Normal
> * Assignee: matz (Yukihiro Matsumoto)
> * Target version: 2.8
> ----------------------------------------
> When Kernel#lambda receives a Proc that is not a lambda,
> it returns it without modification. l propose to change `Kernel#lambda`
> so it always returns a lambda.
> 
> Calling a method called lambda and having it do nothing in effect is
> not very intuitive.
> 
> https://github.com/ruby/ruby/pull/2262
> 
> Judging from marcandre's investigation here: https://bugs.ruby-lang.org/issues/15620#note-1,
> changing the behavior should not cause much breakage, if any.
> 
> 
> This also happens to fix [Bug #15620]
> 
> 
> 
> -- 
> 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>


  reply	other threads:[~2019-12-26  7:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15973.20190702132050@ruby-lang.org>
2019-07-02 13:20 ` [ruby-core:93482] [Ruby master Feature#15973] Make Kernel#lambda always return lambda XrXr
2019-07-02 13:31 ` [ruby-core:93484] " matz
2019-07-02 20:49 ` [ruby-core:93502] [Ruby master Feature#15973] Make it so Kernel#lambda always return a lambda eregontp
2019-07-03  2:03 ` [ruby-core:93506] " shyouhei
2019-07-08  0:20 ` [ruby-core:93597] " XrXr
2019-07-08  0:35 ` [ruby-core:93598] " XrXr
2019-07-08 13:49 ` [ruby-core:93615] " shyouhei
2019-07-09 14:32 ` [ruby-core:93635] " XrXr
2019-07-09 14:38 ` [ruby-core:93636] " eregontp
2019-07-11  5:20 ` [ruby-core:93661] " akr
2019-07-11  8:18 ` [ruby-core:93674] " matz
2019-07-11 10:00 ` [ruby-core:93679] " knu
2019-07-11 11:57 ` [ruby-core:93682] " ruby-core
2019-07-11 16:27 ` [ruby-core:93692] " shyouhei
2019-07-12  4:11 ` [ruby-core:93708] " XrXr
2019-07-12  5:31 ` [ruby-core:93711] " shyouhei
2019-07-12  5:43 ` [ruby-core:93712] " akr
2019-07-12  9:30 ` [ruby-core:93717] " eregontp
2019-07-17 21:20 ` [ruby-core:93822] " XrXr
2019-07-26 17:53 ` [ruby-core:93935] " daniel
2019-07-30  8:08 ` [ruby-core:94038] " ko1
2019-07-30 13:31 ` [ruby-core:94054] " matz
2019-07-30 16:32 ` [ruby-core:94058] " daniel
2019-08-05 16:04 ` [ruby-core:94150] " daniel
2019-09-28  3:46 ` [ruby-core:95140] [Ruby master Feature#15973] Let " XrXr
2019-12-21 21:09 ` [ruby-core:96397] " eregontp
2019-12-24 17:35 ` [ruby-core:96459] " ko1
2019-12-24 17:37 ` [ruby-core:96460] " ko1
2019-12-25 11:04 ` [ruby-core:96463] " eregontp
2019-12-25 11:13 ` [ruby-core:96464] " eregontp
2019-12-25 11:15 ` [ruby-core:96465] " eregontp
2019-12-25 11:20 ` [ruby-core:96467] " zverok.offline
2019-12-25 11:51 ` [ruby-core:96469] " eregontp
2019-12-25 19:34 ` [ruby-core:96475] " zverok.offline
2019-12-26  7:49   ` atdot [this message]
2019-12-26 20:46 ` [ruby-core:96500] " daniel
2020-01-10 22:21 ` [ruby-core:96767] " eregontp
2020-01-16  8:12 ` [ruby-core:96900] " ko1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5C57B954-BC0A-41D4-A647-ABD0B51ACD93@atdot.net \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).