[HN Gopher] Proposal: Downward Assignments
       ___________________________________________________________________
        
       Proposal: Downward Assignments
        
       Author : jbredeche
       Score  : 35 points
       Date   : 2021-04-01 19:20 UTC (3 hours ago)
        
 (HTM) web link (bugs.ruby-lang.org)
 (TXT) w3m dump (bugs.ruby-lang.org)
        
       | MarkLowenstein wrote:
       | Fantastic. Not on-board with the ^^^^ syntax - could be improved.
       | But it reminds me of how sequential-character syntax is limiting,
       | like if you were going to make an integrated circuit in strict 2
       | dimensions, without being able to bridge over traces sometimes in
       | a minimally 3-dimensional way. This is like bringing programming
       | into, literally, a new dimension.
        
         | anthony_romeo wrote:
         | Perhaps they could make use of all of those box-drawing
         | characters that are just taking up space, and use them to pipe
         | the characters in all sorts of directions!
         | 
         | https://en.wikipedia.org/wiki/Box-drawing_character
        
       | gkop wrote:
       | Partisans in favor of spaces over tabs, here's another argument
       | for your arsenal.
        
         | smitty1e wrote:
         | Tabs are evil => https://www.emacswiki.org/emacs/TabsAreEvil
        
           | 8note wrote:
           | I see something different in there.
           | 
           | F(condition1,
           | 
           | Condition2)
           | 
           | Is worse than
           | 
           | F(                 Condition1,            Condition2
           | 
           | )
           | 
           | The problem isn't tabs or spaces, it's trying to align to the
           | length of the function name instead of adding a new line
        
       | aflag wrote:
       | I can only imagine what the elegance and clarity when we start
       | writing code in 3D.
        
       | [deleted]
        
       | viklove wrote:
       | Can't this just be solved by using a do/while loop?
        
       | oivaksef wrote:
       | This is hilarious, and clearly a joke, but it does make one
       | think. I've always thought that it would be nice to have
       | variables which you don't name, which only live over a couple of
       | lines, where it's clear the variable is just for some plumbing
       | and doesn't need a name. I wonder if there is actually something
       | in these two concepts combined
        
         | dragonwriter wrote:
         | > I've always thought that it would be nice to have variables
         | which you don't name, which only live over a couple of lines,
         | where it's clear the variable is just for some plumbing and
         | doesn't need a name
         | 
         | There are several things that involve unnamed, shortlived
         | plumbing vars; as well as various languages pipeline notations,
         | therr is also this in scala lambdas:                 xs.map(x
         | => x + 1)
         | 
         | can be written as:                 xs.map(_ + 1)
         | 
         | and even:                 (xs, ys).zipped.map((x,y)=>x+y)
         | 
         | as:                 (xs, ys).zipped.map(_ + _)
        
         | nonameiguess wrote:
         | tidyverse packages in R do this. Normally, you might have
         | something like this:                   df =
         | someFunctionThatReturnsADataFrame()         newDf =
         | someFunctionThatTakesAndReturnsADataFrame(df)
         | doSomethingTo(df)
         | 
         | Since R lets you define your own operators, they took '%>%' and
         | defined it as "pipe the return value from one function as the
         | first argument to another function," so you can do this:
         | someFunctionThatReturnsADataFrame() %>%
         | someFunctionThatTakesAndReturnsADataFrame() %>%
         | doSomethingTo()
         | 
         | No need to name either the temporaries or the function
         | arguments.
        
           | oivaksef wrote:
           | IRB the interactive ruby shell has _ which references the
           | return value of the last command. So
           | 
           | 10 + 10 puts _ # prints 20
           | 
           | but that isn't available in ruby itself
        
         | 8note wrote:
         | How do you reference a variable for plumbing if it doesn't have
         | a name?
        
           | inivekin wrote:
           | Wouldn't any concatenate language fit the bill?
           | https://concatenative.org/
        
           | thepratt wrote:
           | Would Elixir's pipe - https://elixir-lang.org/getting-
           | started/enumerables-and-stre... - or Haskell's function
           | composition - https://wiki.haskell.org/Function_composition -
           | fit the criteria?
        
             | oivaksef wrote:
             | Those would. The Elixir style feels nice. I wonder if
             | something like that could make it into Ruby 4
        
         | kazinator wrote:
         | We already have:
         | 
         | - partial application notation with numbered arguments
         | 
         | - pattern matching
         | 
         | - anaphoric if and related notations
         | 
         | - point-free form (no names at all)
        
       | twic wrote:
       | I thought this might be some inverse of upvar from Tcl (which is
       | not an April Fool):
       | 
       | https://www.tcl.tk/man/tcl/TclCmd/upvar.htm
        
       | multiplegeorges wrote:
       | A truly inspired proposal!
        
       | bcardarella wrote:
       | The number of people that don't have their guard up on April 1 is
       | always astounding.
        
       ___________________________________________________________________
       (page generated 2021-04-01 23:01 UTC)