[elixir-core:7150] Re: Proposal: pipe and assign syntax

2017-05-19 Thread Ben Wilson
This has been proposed before, and it was rejected then as well. You're 
only saving a few characters, and it obfuscates that two completely 
different things are happening (assignment, function calling).

On Friday, May 19, 2017 at 1:27:29 PM UTC-4, OvermindDL1 wrote:
>
> Actually that specific example would not work now that I think of it, but 
> you could do it via a bit more macro-work.
>
>
> On Friday, May 19, 2017 at 11:26:19 AM UTC-6, OvermindDL1 wrote:
>>
>> You could easily make that into a library (in fact similar ones already 
>> exist, though not for 'just' that feature).
>>
>> Just define a new operator, say `<|>` since you are piping 'both ways' 
>> I'd say as a macro, then you can do it, it might even be as simple as 
>> (untested):
>> ```elixir
>> defmacro left <|> right do
>>   quote do
>> unquote(left) = unquote(left) |> unquote(right)
>>   end
>> end
>> ```
>> Then you could do:
>> ```elixir
>> conn
>> <|> put_assign(:blah, :bloop)
>>  |> more_stuff()
>>  |> render(:index)
>> ```
>> or so.  Easily done as a library though, or just add it to your own 
>> project and require it where you want.
>>
>>
>>
>> On Friday, May 19, 2017 at 11:06:28 AM UTC-6, Mario Campa wrote:
>>>
>>> Hello, 
>>>
>>> I'm new to Elixir, so forgive me if this idea sounds silly.
>>>
>>> I keep repeating this pattern in multiple controllers:
>>>
>>> conn = Plug.Conn.put_session(conn, :foo, bar)
>>>
>>> or
>>>
>>> conn = conn |> Plug.Conn.put_session(:foo, bar)
>>>
>>>
>>> IMO it would be cool to have a shorter version to this where I can pipe 
>>> and assign like this:
>>>
>>> conn |>= Plug.Conn.put_session(:foo, bar)
>>>
>>>
>>> Similar to
>>>
>>> a = a + 2
>>> # or
>>> a += 2
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/14a96e51-b032-4907-903a-7d35df33b6e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elixir-core:7149] Re: Proposal: pipe and assign syntax

2017-05-19 Thread OvermindDL1
Actually that specific example would not work now that I think of it, but 
you could do it via a bit more macro-work.


On Friday, May 19, 2017 at 11:26:19 AM UTC-6, OvermindDL1 wrote:
>
> You could easily make that into a library (in fact similar ones already 
> exist, though not for 'just' that feature).
>
> Just define a new operator, say `<|>` since you are piping 'both ways' I'd 
> say as a macro, then you can do it, it might even be as simple as 
> (untested):
> ```elixir
> defmacro left <|> right do
>   quote do
> unquote(left) = unquote(left) |> unquote(right)
>   end
> end
> ```
> Then you could do:
> ```elixir
> conn
> <|> put_assign(:blah, :bloop)
>  |> more_stuff()
>  |> render(:index)
> ```
> or so.  Easily done as a library though, or just add it to your own 
> project and require it where you want.
>
>
>
> On Friday, May 19, 2017 at 11:06:28 AM UTC-6, Mario Campa wrote:
>>
>> Hello, 
>>
>> I'm new to Elixir, so forgive me if this idea sounds silly.
>>
>> I keep repeating this pattern in multiple controllers:
>>
>> conn = Plug.Conn.put_session(conn, :foo, bar)
>>
>> or
>>
>> conn = conn |> Plug.Conn.put_session(:foo, bar)
>>
>>
>> IMO it would be cool to have a shorter version to this where I can pipe 
>> and assign like this:
>>
>> conn |>= Plug.Conn.put_session(:foo, bar)
>>
>>
>> Similar to
>>
>> a = a + 2
>> # or
>> a += 2
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/c63edaf0-5154-43d4-8158-5c3321f04dda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elixir-core:7148] Re: Proposal: pipe and assign syntax

2017-05-19 Thread OvermindDL1
You could easily make that into a library (in fact similar ones already 
exist, though not for 'just' that feature).

Just define a new operator, say `<|>` since you are piping 'both ways' I'd 
say as a macro, then you can do it, it might even be as simple as 
(untested):
```elixir
defmacro left <|> right do
  quote do
unquote(left) = unquote(left) |> unquote(right)
  end
end
```
Then you could do:
```elixir
conn
<|> put_assign(:blah, :bloop)
 |> more_stuff()
 |> render(:index)
```
or so.  Easily done as a library though, or just add it to your own project 
and require it where you want.



On Friday, May 19, 2017 at 11:06:28 AM UTC-6, Mario Campa wrote:
>
> Hello, 
>
> I'm new to Elixir, so forgive me if this idea sounds silly.
>
> I keep repeating this pattern in multiple controllers:
>
> conn = Plug.Conn.put_session(conn, :foo, bar)
>
> or
>
> conn = conn |> Plug.Conn.put_session(:foo, bar)
>
>
> IMO it would be cool to have a shorter version to this where I can pipe 
> and assign like this:
>
> conn |>= Plug.Conn.put_session(:foo, bar)
>
>
> Similar to
>
> a = a + 2
> # or
> a += 2
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/bddac7ae-b4ad-47d7-842e-8d49609e062e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elixir-core:7147] Proposal: pipe and assign syntax

2017-05-19 Thread Mario Campa
Hello, 

I'm new to Elixir, so forgive me if this idea sounds silly.

I keep repeating this pattern in multiple controllers:

conn = Plug.Conn.put_session(conn, :foo, bar)

or

conn = conn |> Plug.Conn.put_session(:foo, bar)


IMO it would be cool to have a shorter version to this where I can pipe and 
assign like this:

conn |>= Plug.Conn.put_session(:foo, bar)


Similar to

a = a + 2
# or
a += 2


-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/b962b87f-94aa-436f-94f9-9027d7eb8121%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7145] [Proposal] Improve supported syntax in Doctest

2017-05-19 Thread José Valim
We should not import flush for all of the reasons said before. Prefer to
use receive.
-- 


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KAsdw1eRDQxtp-KwwW9AfLuhZt364-Y9ruE7xnLNedXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7144] [Proposal] Improve supported syntax in Doctest

2017-05-19 Thread José Valim
If they fit under the first case, then sure. But no special case should be
added and we should not promote using comments for return types. If you
write this:

IEx> 1
#=> :oops

We won't compare 1 with :oops. And there is no purpose in writing in the
style above as nothing will be tested anyway.

-- 


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JX0Zsi2FfLsdayBU9y%2B%2Bwo6v%2BOYLFjdOCamVeXjwLeTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7143] [Proposal] Improve supported syntax in Doctest

2017-05-19 Thread eksperimental
> I don't think we should support IEx helpers because although users will
> often try them in IEx, they may also try in their apps and any IEx helper
> will fail. And it will be confusing especially for new users which are not
> quite familiar with what is part of IEx and what is Kernel.

That's a really good point.

Should we only import `flush`?

Could you also care to exlain why not support "#=> ". It is not clear yo me yet 
why they are not
supported by IEx when they are just comments, no different than what we will 
support in bullet 1.
 

On Fri, 19 May 2017 16:24:42 +
José Valim  wrote:

> We should support the first bullet, which is the comments syntax if we
> don't support it yet.
> 
> I don't think we should support IEx helpers because although users will
> often try them in IEx, they may also try in their apps and any IEx helper
> will fail. And it will be confusing especially for new users which are not
> quite familiar with what is part of IEx and what is Kernel.

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/20170519232857.1487edae.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7142] [Proposal] Improve supported syntax in Doctest

2017-05-19 Thread José Valim
We should support the first bullet, which is the comments syntax if we
don't support it yet.

I don't think we should support IEx helpers because although users will
often try them in IEx, they may also try in their apps and any IEx helper
will fail. And it will be confusing especially for new users which are not
quite familiar with what is part of IEx and what is Kernel.
-- 


*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BMrZdOyEZDf%3D%2BoKZrm4P192Suvwz-tWQz5m11MXucCvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7140] [Proposal] Improve supported syntax in Doctest

2017-05-19 Thread eksperimental
So, where should we move from here?

On Mon, 8 May 2017 18:37:50 +0200
Andrea Leopardi  wrote:

> FWIW, when I need to test messages today I use `receive` in doctests as well.
> 
> On May 8, 2017, 6:35 PM +0200, eksperimental , 
> wrote:
> > I see your point. But I think it would simplify things if what's available 
> > in IEx is available
> > in doctests, since that's the environment it is supposed to be running in.
> >
> > On Mon, 8 May 2017 18:28:32 +0200
> > José Valim  wrote:
> >
> > > Then you can use the File API to do exactly that. Such as File.ls! and
> > > File.cwd!.
> > >
> > >
> > >
> > > *José Valim*
> > > www.plataformatec.com.br
> > > Skype: jv.ptec
> > > Founder and Director of R&D
> > >
> > > On Mon, May 8, 2017 at 6:26 PM, eksperimental  > > wrote:
> > >
> > > > They could be useful for doctests such when dealing with file and dirs
> > > > creation and removal,
> > > > you cd/1 a dir, and then mkdir_p, and `touch` a file and `ls` the 
> > > > contents
> > > > of the specific dir,
> > > >
> > > >
> > > >
> > > > On Mon, 8 May 2017 18:17:33 +0200
> > > > José Valim  wrote:
> > > >
> > > > > pwd and ls are not going to be effective in doctests as the results 
> > > > > will
> > > > be
> > > > > highly dependent of the user directory and what is on their machine.
> > > > >
> > > > >
> > > > >
> > > > > *José Valim*
> > > > > www.plataformatec.com.br
> > > > > Skype: jv.ptec
> > > > > Founder and Director of R&D
> > > > >
> > > > > On Mon, May 8, 2017 at 5:16 PM, eksperimental <
> > > > eksperimen...@autistici.org
> > > > > wrote:
> > > > >
> > > > > > José Valim  wrote:
> > > > > > > We should support regular comments (a-I). We should not support
> > > > (a-II)
> > > > > > and
> > > > > > > (a-III) because they are not valid in IEx.
> > > > > >
> > > > > > How come, since they are all treated as comments by IEx.
> > > > > >
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "elixir-lang-core" group.
> > > > > > To unsubscribe from this group and stop receiving emails from it, 
> > > > > > send
> > > > an
> > > > > > email to elixir-lang-core+unsubscr...@googlegroups.com.
> > > > > > To view this discussion on the web visit 
> > > > > > https://groups.google.com/d/
> > > > > > msgid/elixir-lang-core/20170508221600.66851fc4.
> > > > > > eksperimental%40autistici.org.
> > > > > > For more options, visit https://groups.google.com/d/optout.
> > > > > >
> > > > >
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "elixir-lang-core" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send 
> > > > an
> > > > email to elixir-lang-core+unsubscr...@googlegroups.com.
> > > > To view this discussion on the web visit https://groups.google.com/d/
> > > > msgid/elixir-lang-core/20170508232653.0388c5f1.
> > > > eksperimental%40autistici.org.
> > > > For more options, visit https://groups.google.com/d/optout.
> > > >
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "elixir-lang-core"
> > group. To unsubscribe from this group and stop receiving emails from it, 
> > send an email to
> > elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on 
> > the web visit
> > https://groups.google.com/d/msgid/elixir-lang-core/20170508233503.5b997d54.eksperimental%40autistici.org.
> > For more options, visit https://groups.google.com/d/optout.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/20170519231133.355e0cdf.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.


Re: [elixir-core:7140] Regex related new changes in Elixir

2017-05-19 Thread eksperimental
Thank you for the clear explanation José.
(I forgot to say thanks before)


On Tue, 9 May 2017 00:04:04 +0200
José Valim  wrote:

> More info here:
> https://github.com/elixir-lang/elixir/blob/3c22fa1b00369b5f29f42884f0fe664e5ed2ebc6/lib/elixir/lib/regex.ex#L36-L47
> 
> 
> 
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
> 
> On Mon, May 8, 2017 at 11:45 PM, eksperimental 
> wrote:
> 
> > I've been following the recent changes and I can see that there are a lot
> > of changes that are
> > getting rid of the Regular expressions that are being ditched.
> > I read issue:
> > Support Erlang 20 new features
> > https://github.com/elixir-lang/elixir/issues/5851
> > that mentions: No longer use regexes in Elixir as they are not portable
> > from 19->20
> >
> > Could anybody explain that this means, how this affect the Elixir project
> > and if this affects users.
> > thank you.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "elixir-lang-core" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to elixir-lang-core+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/
> > msgid/elixir-lang-core/20170509044514.3d2c0295.
> > eksperimental%40autistici.org.
> > For more options, visit https://groups.google.com/d/optout.
> >
> 

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/20170519231035.770ca7a5.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.