Re: [go-nuts] Underscores true or false?

382 views
Skip to first unread message

Kyle Lemons

unread,
May 30, 2013, 5:16:24 PM5/30/13
to Joel Eidsath, golang-nuts
http://play.golang.org/p/NTJ-AnaPgO

package main

import "fmt"

func main() {
if despiteallobjections 2 + 2 == 5 {
panic("Goodbye, cruel world!")
}
fmt.Println("Phew, still safe.")
}


On Thu, May 30, 2013 at 11:14 AM, Joel Eidsath <jeid...@gmail.com> wrote:
Does anyone have good examples of Go syntax abuse?

http://play.golang.org/p/sH0IEFofCQ

package main

import "fmt"
var then bool

func main() {
        if _ = true
        then{
                fmt.Printf("Underscores are true!")
        }else{
                fmt.Printf("Underscores are false!")}
}

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kamil Kisiel

unread,
May 30, 2013, 5:32:32 PM5/30/13
to golan...@googlegroups.com
From a bug I recently reported:

Rob Pike

unread,
May 30, 2013, 9:14:14 PM5/30/13
to Kamil Kisiel, golan...@googlegroups.com
not an improvement, just an expansion of the idea:

http://play.golang.org/p/3pNo5hZ0NT

Daniel Jo

unread,
May 30, 2013, 10:22:27 PM5/30/13
to Rob Pike, Kamil Kisiel, golan...@googlegroups.com
I'm seriously confused. Why does the lexer have those symbols?

-Daniel


On Thu, May 30, 2013 at 7:14 PM, Rob Pike <r...@golang.org> wrote:
not an improvement, just an expansion of the idea:

http://play.golang.org/p/3pNo5hZ0NT
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


David Symonds

unread,
May 30, 2013, 10:47:36 PM5/30/13
to Daniel Jo, Rob Pike, Kamil Kisiel, golan...@googlegroups.com
On Fri, May 31, 2013 at 12:22 PM, Daniel Jo <ost...@gmail.com> wrote:

> I'm seriously confused. Why does the lexer have those symbols?

It's to make Kafka parseable as Go code.

Martin Angers

unread,
May 31, 2013, 8:24:43 AM5/31/13
to golan...@googlegroups.com, Daniel Jo, Rob Pike, Kamil Kisiel
Haha! Can't test it locally right now, but is it just in the Playground?

minux

unread,
May 31, 2013, 8:39:29 AM5/31/13
to Martin Angers, golan...@googlegroups.com, Daniel Jo, Rob Pike, Kamil Kisiel

On Fri, May 31, 2013 at 8:24 PM, Martin Angers <martin....@gmail.com> wrote:
Haha! Can't test it locally right now, but is it just in the Playground?
It's possible to run locally, but you will have to invoke the toolchain directly (instead of using "go run").

$ cat 3pNo5hZ0NT.go
notwithstanding package main

whereas import "fmt"

func main(thetruthofthematter) {
        if despiteallobjections 2 + 2 == 5 {
                panic("Goodbye, cruel world!")
        }
        fmt.Println(insofaras "Phew, still safe.")
}
$ go run 3pNo5hZ0NT.go
3pNo5hZ0NT.go:1:1: expected 'package', found 'IDENT' notwithstanding
$ go tool 6g 3pNo5hZ0NT.go && go tool 6l 3pNo5hZ0NT.6 && ./6.out
Phew, still safe.

Reply all
Reply to author
Forward
0 new messages