News for hackers. Stuff that matters.
Re:Python with Braces by Apreche on Sunday February 09, 2014 @05:54PM (#7207772)
What if you want to make a dictionary?

you = {'are': 'screwed'}

Re:Python with Braces by bluehex on Sunday February 09, 2014 @06:03PM (#7207827)
I don't see the ambiguity. Braces in expression position -> dict constructor. JavaScript is a fine example of how this is not a problem.
Re:Python with Braces by chewxy on Sunday February 09, 2014 @06:31PM (#7207978)
Actually, it is. It is very easy to confuse an object literal and a block in Javascript. In fact, in the book I am writing[0], I dedicate an entire chapter to using this ambiguity to write arsehole code. Here's another example[1]

[0] https://leanpub.com/underhandedjavascript or its alternate title: https://leanpub.com/jsinterviewquestions [1] Slide 21 (1-index): https://speakerdeck.com/chewxy/underhanded-javascript-how-to...

EDIT:

For those of you who do not want to click through my self promotional links, try this in your browser:

  {}[0] == true // false
  
  {}[1] == true // true
  
  !{}[0] == true // true
  
  !{}[1] == true // true
Re:Python with Braces by lowboy on Sunday February 09, 2014 @06:51PM (#7208073)
Do you have any non-contrived examples of confusing an object literal and a block?

Because as soon as you see this

    { identifier:
You know it's an object literal and not a block.
Re:Python with Braces by bcj on Sunday February 09, 2014 @07:02PM (#7208132)

    if foo == bar {
        baz(), lorem(), ipsum()
    }
could be:

    if foo == bar:
        baz(), lorem(), ipsum()
or:

    if foo == bar:
        {baz(), lorem(), ipsum()}
Admittedly, this code doesn't have a functional difference. With a bit more thought, I may be able to come up with code where that matters.
Re:Python with Braces by shuzchen on Sunday February 09, 2014 @06:07PM (#7207848)
Let's first forget that this is a crazy idea:

This is doable since dictionaries and blocks show up in different contexts. A block never follows =,:, ;, or (, so with a context sensitive grammar this can be accomplished. I guess it depends how they intend to support anonymous functions (def{}?)

Re:Python with Braces by lutusp on Sunday February 09, 2014 @05:59PM (#7207803)
Surely they accommodate this syntax in the scheme. The whole project would collapse if they didn't.