From: Matthew Kerwin Date: 2013-01-08T13:34:12+09:00 Subject: Re: How to identify whether a line of code will return? --047d7b2e0f0509b14504d2bf7596 Content-Type: text/plain; charset=ISO-8859-1 On 8 January 2013 14:09, Josh Cheek wrote: > Thought maybe I could solve it with regexes, but I've come to the > conclusion that I don't understand the return keyword at all :/ > > I can't explain cases like this, for example: > > $ echo '-> { a = (return && 1) }' | ruby -c > -:1: void value expression > -> { a = (return && 1) } > ^ > > $ echo '-> { a = (1 && return) }' | ruby -c > Syntax OK > I agree, it's pretty weird. I would guess the "void value expression" error is actually the parser complaining that the left hand operand of (({&&}}) is void. The right hand side is allowed to be void so we can do things like (({foo.bad? && asplode})). Odd that it doesn't mind the right hand side of the assignment operator being void; I guess the parser can't determine, and by the time it's evaluated at runtime, the (({return})) has already executed, so the point is moot. By the way, if you do manage to solve the halting problem, please let us all know. Cheers! -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd --047d7b2e0f0509b14504d2bf7596 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 8 January 2013 14:09, Josh Cheek <= josh.cheek@gmail.= com> wrote:
Thought maybe I could solve it with regexes, but I've come to the = conclusion that I don't understand the return keyword at all :/

I can't explain cases like this, for example:

$ echo '-> { a =3D (return && = 1) }' | ruby -c
-:1: void value expression<= /div>
-> { a =3D (return && 1) }
=A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^

$ echo '-> { a =3D (1 && return) }' | ruby -c=
Syntax OK

I agree, it's pretty weird. =A0I would guess the= "void value expression" error is actually the parser complaining= that the left hand operand of (({&&}}) is void. =A0The right hand = side is allowed to be void so we can do things like (({foo.bad? && = asplode})). =A0Odd that it doesn't mind the right hand side of the assi= gnment operator being void; I guess the parser can't determine, and by = the time it's evaluated at runtime, the (({return})) has already execut= ed, so the point is moot.

By the way,= if you do manage to solve the halting problem, please let us all know.

Cheers!
--
=A0 Matthew Kerwin, B.Sc (CompSci) (Hons)=
=A0 http://= matthew.kerwin.net.au/
=A0 ABN: 59-013-727-651

=A0 "You&= #39;ll never find a programming language that frees
=A0 you from the burden of clarifying your ideas." - xkcd
--047d7b2e0f0509b14504d2bf7596--