Quantcast

>mkdir

classic Classic list List threaded Threaded
32 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

>mkdir

Razvan Cojocaru-2

Surprisingly, this works well. What surprised me is that it works with or without a space between > and mkdir…

val > = DefaultShell;

>mkdir "dir1"

http://github.com/razie/scalafs/blob/master/src/main/scala/razie/fs/proto1/Sf1App.scala

$ scala

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.

6.0_22).

Type in expressions to have them evaluated.

Type :help for more information.

 

scala> val > = System.out

>: java.io.PrintStream = java.io.PrintStream@24f90b1a

 

scala> >println ("well, hello there")

well, hello there

 

scala>

Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toys: Scripster and Gremlins
Follow me: RSS Feed, Twitter, GitHub.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
How is that different from 2>1 and 2 > 1 working same?

-- Jim


On Thu, Jan 20, 2011 at 2:40 PM, Razvan Cojocaru <[hidden email]> wrote:

Surprisingly, this works well. What surprised me is that it works with or without a space between > and mkdir…

val > = DefaultShell;

>mkdir "dir1"

http://github.com/razie/scalafs/blob/master/src/main/scala/razie/fs/proto1/Sf1App.scala

$ scala

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.

6.0_22).

Type in expressions to have them evaluated.

Type :help for more information.

 

scala> val > = System.out

>: java.io.PrintStream = java.io.PrintStream@24f90b1a

 

scala> >println ("well, hello there")

well, hello there

 

scala>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Rex Kerr-2
In your example, > is a method.  In Razvan's, it's a val.

If you think the distinction is comes from the lexer, then you expect no difference. If you expect it's at the level of the parser, then you expect a difference.

It's the same sort of thing with
  "Hi".length
  "Hi" length
  "Hi"length
If you believe that the separation is at the level of the lexer, you think the third is the same as the first two.  If you think it's at the parser level, then the third seems like it could be different (e.g. fail to work).

Similarly,
  4.toLong
  4 toLong
  4toLong
gives different expectations depending on what you think is being handled by the lexer and what is handled by the parser.

  --Rex

P.S. "Hi"length works.  4toLong doesn't.  So I'm not sure there's any super-obvious expectation for how these things ought to behave.  If you think about it for a while, you can probably come up with some rationalizations.


On Thu, Jan 20, 2011 at 7:48 PM, Jim Balter <[hidden email]> wrote:
How is that different from 2>1 and 2 > 1 working same?

-- Jim



On Thu, Jan 20, 2011 at 2:40 PM, Razvan Cojocaru <[hidden email]> wrote:

Surprisingly, this works well. What surprised me is that it works with or without a space between > and mkdir…

val > = DefaultShell;

>mkdir "dir1"

http://github.com/razie/scalafs/blob/master/src/main/scala/razie/fs/proto1/Sf1App.scala

$ scala

Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.

6.0_22).

Type in expressions to have them evaluated.

Type :help for more information.

 

scala> val > = System.out

>: java.io.PrintStream = java.io.PrintStream@24f90b1a

 

scala> >println ("well, hello there")

well, hello there

 

scala>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
On Thu, Jan 20, 2011 at 5:24 PM, Rex Kerr <[hidden email]> wrote:
In your example, > is a method.  In Razvan's, it's a val.

Of course, but that's about as far from relevant as one can get. It would be a rather arcane language that treated operator characters as delimited from letters and digits in infix position but not in unary position, let alone that made the sort of distinction you refer to.


-- Jim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: >mkdir

Razvan Cojocaru-2

What’s the difference between the compiler pointing out a mistake and accepting anything that may even remotely compile…?

 

Hmm, this looks unfair, although logical and… arcane?

 

scala> val >p = System.out

<console>:1: error: illegal start of simple pattern

       val >p = System.out

              ^

Not regular, hence surprising…

 

This explains it though – I was under the impression that operator names can be any combination… my bad!

 

scala> class G { def >>print { >print "hehe" } }

<console>:1: error: '=' expected but identifier found.

       class G { def >>print { >print "hehe" } }

                               ^

<console>:1: error: illegal start of simple expression

       class G { def >>print { >print "hehe" } }

                                               ^

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Jim Balter
Sent: January-20-11 9:14 PM
To: Rex Kerr
Cc: Razvan Cojocaru; [hidden email]
Subject: Re: [scala-user] >mkdir

 

On Thu, Jan 20, 2011 at 5:24 PM, Rex Kerr <[hidden email]> wrote:

In your example, > is a method.  In Razvan's, it's a val.


Of course, but that's about as far from relevant as one can get. It would be a rather arcane language that treated operator characters as delimited from letters and digits in infix position but not in unary position, let alone that made the sort of distinction you refer to.


-- Jim

Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toys: Scripster and Gremlins
Follow me: RSS Feed, Twitter, GitHub.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
On Thu, Jan 20, 2011 at 10:05 PM, Razvan Cojocaru <[hidden email]> wrote:

There's a language spec that determines what should be compilable and that's what the compiler accepts (modulo compiler bugs). If the code violates the spec, then the compiler should point out that it's a mistake. If it doesn't violate the spec, then there is no way for the compiler to know that it's a mistake. But I'm not clear on what you think is a mistake in what you gave previously. Why should >mkdir be a mistake if > mkdir isn't, or v.v.?
 

Hmm, this looks unfair, although logical and… arcane?

 

scala> val >p = System.out

<console>:1: error: illegal start of simple pattern

       val >p = System.out

              ^

Not regular, hence surprising…


How is it not regular (or unfair, or even arcane)?

  val p q = System.out

yields the same error message; in both cases there are two identifiers between val and =. As far as Scala is concerned, > and p are both perfectly acceptable identifiers. This is unusual compared to some other languages, but one very venerable language has similar rules, and it is a powerful feature of Scala because it eliminates the distinction between operators and method names and increases the ability to create DSLs.
 

 

This explains it though – I was under the impression that operator names can be any combination… my bad!


But that obviously cannot be, as my 2>1 example pointed out. Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs. They can't be mixed, with the exception that the latter sequence can be followed by an underscore and a sequence of operator characters, e.g.: unary_+ or frob1_$_^*&#*^#
 

 

scala> class G { def >>print { >print "hehe" } }

<console>:1: error: '=' expected but identifier found.

       class G { def >>print { >print "hehe" } }

                               ^

<console>:1: error: illegal start of simple expression

       class G { def >>print { >print "hehe" } }

                                               ^


In both cases you have two identifiers in a row. As before,

  class G { def qq print { q print "hehe" } }


gets the same errors.

-- Jim

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Jim Balter
Sent: January-20-11 9:14 PM
To: Rex Kerr
Cc: Razvan Cojocaru; [hidden email]
Subject: Re: [scala-user] >mkdir

 

On Thu, Jan 20, 2011 at 5:24 PM, Rex Kerr <[hidden email]> wrote:

In your example, > is a method.  In Razvan's, it's a val.


Of course, but that's about as far from relevant as one can get. It would be a rather arcane language that treated operator characters as delimited from letters and digits in infix position but not in unary position, let alone that made the sort of distinction you refer to.


-- Jim


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Daniel Sobral
Not only underscore and dollar sign are considered to be letters, though the dollar sign is reserved for the compiler and should not be used, but they are considered uppercase letters! :-)

On Fri, Jan 21, 2011 at 04:53, Jim Balter <[hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim



--
Daniel C. Sobral

I travel to the future all the time.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

John Ky
In reply to this post by Jim Balter-2
And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Razvan Cojocaru-2
Now see why my impression and then surprise? In my mind at the time, there was no difference between 4mkdir and >mkdir.

Thanks,
Razvan

On 2011-01-21, at 7:28 AM, John Ky <[hidden email]> wrote:

And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim

Razvan Cojocaru,
Work: http://www.sigma-systems.com
Playground: http://wiki.homecloud.ca
Latest cool toys: Scripster and Gremlins
Follow me: RSS Feed, Twitter, GitHub.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Josh Suereth
Yes, I can understand that surprise coming from other languages.  It's a neat side-corner of scala.   I still recommend (in my personal style-guide at least) that you put separation before and after 'operator-notation' methods.  

As an aside, I'm not sure why this argument became so heated but I hope it is not a trend that continues on the mailing list.  Someone expressed surprise at something someone unfamiliar with Scala's formal definition would surprised about, especially coming from other languages.   Let's be careful with how we word our responses.

- Josh

On Fri, Jan 21, 2011 at 9:15 AM, Razvan Cojocaru <[hidden email]> wrote:
Now see why my impression and then surprise? In my mind at the time, there was no difference between 4mkdir and >mkdir.

Thanks,
Razvan

On 2011-01-21, at 7:28 AM, John Ky <[hidden email]> wrote:

And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email][hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email][hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
In reply to this post by Razvan Cojocaru-2
4mkdir simply isn't a legal token ... although I believe that may be a bug. AFAICS, there is nothing in the SLS that says that it should not be the two tokens 4 and mkdir. Not that I think it should, but then the SLS should say something about digits followed immediately by identifier characters being illegal except as explicitly allowed (e.g., 4L, 4e1).

-- Jim

P.S. On "heat", I didn't see any.

On Fri, Jan 21, 2011 at 6:15 AM, Razvan Cojocaru <[hidden email]> wrote:
Now see why my impression and then surprise? In my mind at the time, there was no difference between 4mkdir and >mkdir.

Thanks,
Razvan

On 2011-01-21, at 7:28 AM, John Ky <[hidden email]> wrote:

And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email][hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email][hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
In reply to this post by Josh Suereth
On Fri, Jan 21, 2011 at 7:30 AM, Josh Suereth <[hidden email]> wrote:
Yes, I can understand that surprise coming from other languages.

In almost all languages, >mkdir is two tokens, as it is in Scala. It would be surprising for it to be one token, and that would make things like 2>1 (or chdir>mkdir) misparse. Note that this sort of thing is determined by the lexer in virtually every language -- the parser has nothing to do with it. e.g., in the case of "Hi"length or 4toLong, the parser sees either two tokens, if the lexer separates them (as Scala and most other languages do for the former), or none at all if the lexer flags them as an error (as Scala and most other languages do for the latter).
 
 It's a neat side-corner of scala.

The neat side-corner of Scala is not that it separates operator characters from identifier characters, as most languages do, but that it allows strings of operator characters to be identifiers.
 
  I still recommend (in my personal style-guide at least) that you put separation before and after 'operator-notation' methods.  

As an aside, I'm not sure why this argument became so heated but I hope it is not a trend that continues on the mailing list.  Someone expressed surprise at something someone unfamiliar with Scala's formal definition would surprised about, especially coming from other languages.   Let's be careful with how we word our responses.

Let's be careful about misrepresenting what has been written and inferring mental states and attitudes -- best to omit such comments that verge into the territory of ad hominem.

-- Jim

On Fri, Jan 21, 2011 at 9:15 AM, Razvan Cojocaru <[hidden email]> wrote:
Now see why my impression and then surprise? In my mind at the time, there was no difference between 4mkdir and >mkdir.

Thanks,
Razvan

On 2011-01-21, at 7:28 AM, John Ky <[hidden email]> wrote:

And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email][hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email][hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Randall R Schulz-2
On Saturday January 22 2011, Jim Balter wrote:
> On Fri, Jan 21, 2011 at 7:30 AM, Josh Suereth
<[hidden email]>wrote:
> > Yes, I can understand that surprise coming from other languages.
>
> In almost all languages, >mkdir is two tokens, as it is in Scala. ...

The Lisp family of languages deserves representation here, and it would
not treat this as two tokens.


> ...
>
> -- Jim


Randall Schulz
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Josh Suereth
In reply to this post by Jim Balter-2
yes, but people are also used to separating methods using '.' in C-style languages, hence the surprise.  Not everyone thinks from a language design perspective, or makes the connection that operator-notation would parse like normal operators do in other languages.  They fit into the 'method call' mental bucket for me, and hence assuming there needs to be something separating the two tokens (be it '.' or ' ').

Why must you tell me I'm wrong when I say 'this surprised me'.  It's a notion of emotion on my own person.

The argument of whether or not this tokenizing/parsing is common on other languages is a different one which I was never arguing.  The statement I made was whether or not an average developer would be surprised about method calls not requiring some kind of separator character, and I believe this to be true statement.

On Sat, Jan 22, 2011 at 12:32 PM, Jim Balter <[hidden email]> wrote:
On Fri, Jan 21, 2011 at 7:30 AM, Josh Suereth <[hidden email]> wrote:
Yes, I can understand that surprise coming from other languages.

In almost all languages, >mkdir is two tokens, as it is in Scala. It would be surprising for it to be one token, and that would make things like 2>1 (or chdir>mkdir) misparse. Note that this sort of thing is determined by the lexer in virtually every language -- the parser has nothing to do with it. e.g., in the case of "Hi"length or 4toLong, the parser sees either two tokens, if the lexer separates them (as Scala and most other languages do for the former), or none at all if the lexer flags them as an error (as Scala and most other languages do for the latter).
 
 It's a neat side-corner of scala.

The neat side-corner of Scala is not that it separates operator characters from identifier characters, as most languages do, but that it allows strings of operator characters to be identifiers.
 
  I still recommend (in my personal style-guide at least) that you put separation before and after 'operator-notation' methods.  

As an aside, I'm not sure why this argument became so heated but I hope it is not a trend that continues on the mailing list.  Someone expressed surprise at something someone unfamiliar with Scala's formal definition would surprised about, especially coming from other languages.   Let's be careful with how we word our responses.

Let's be careful about misrepresenting what has been written and inferring mental states and attitudes -- best to omit such comments that verge into the territory of ad hominem.

-- Jim


On Fri, Jan 21, 2011 at 9:15 AM, Razvan Cojocaru <[hidden email]> wrote:
Now see why my impression and then surprise? In my mind at the time, there was no difference between 4mkdir and >mkdir.

Thanks,
Razvan

On 2011-01-21, at 7:28 AM, John Ky <[hidden email]> wrote:

And also stuff like this:

val x_: Int = 1

sucking in operators into the identifier stopped me trailing my variable names with underscore real quick.

Cheers,

-John

On 21 January 2011 17:53, Jim Balter <[hidden email][hidden email]> wrote:
On Thu, Jan 20, 2011 at 10:47 PM, Jim Balter <[hidden email][hidden email]> wrote:

Identifiers in Scala are either a sequence of operator characters or a letter followed by a sequence of letters, digits, underscores, or dollar signs.

Sorry, I misstated this. It's actually a letter followed by a sequence of letters or digits, where underscore and dollar sign are considered to be letters. The difference is that my previous formulation doesn't include identifiers starting with an underscore or dollar sign.

-- Jim




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2

On Sat, Jan 22, 2011 at 9:57 AM, Josh Suereth <[hidden email]> wrote:
Why must you tell me I'm wrong when I say 'this surprised me'.  It's a notion of emotion on my own person.


Again, I urge you not to take this route. I told you no such thing, but there are technical points that argue that one should not be surprised that >mkdir is parsed as two tokens. Of course, one is free to be surprised about all sorts of things even though they are to be expected if one thinks about them a little bit.

-- Jim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Daniel Sobral
In reply to this post by Randall R Schulz-2
Well, if the idea is provide examples to the contrary, >R is one of
Forth's standard words.

On Sat, Jan 22, 2011 at 15:40, Randall R Schulz <[hidden email]> wrote:

> On Saturday January 22 2011, Jim Balter wrote:
>> On Fri, Jan 21, 2011 at 7:30 AM, Josh Suereth
> <[hidden email]>wrote:
>> > Yes, I can understand that surprise coming from other languages.
>>
>> In almost all languages, >mkdir is two tokens, as it is in Scala. ...
>
> The Lisp family of languages deserves representation here, and it would
> not treat this as two tokens.
>
>
>> ...
>>
>> -- Jim
>
>
> Randall Schulz
>



--
Daniel C. Sobral

I travel to the future all the time.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Josh Suereth
In reply to this post by Jim Balter-2

I agree that from a parsing/lexing perspective I think the idea that no space is required between operator tokens is valid.  However, the fact that there is no space required between an identifier and a method call would be surprising if you didn't see the concrete identifier as an operator (which I'd argue is a stretch).  There's also the fact that some of the things I've read on scala imply that method names can be 'anything' whereas this is not true.  I believe this helps propogate the myth that spaces are needed, because of the assumption that this would be the only way to split up identifiers.

In any case, if one does not know the identifier rules from the SLS (which I'd argue is quite a few people on this list) then the argument that these things should be intuitive with a little thinking is just absurd.

On Sat, Jan 22, 2011 at 1:23 PM, Jim Balter <[hidden email]> wrote:

On Sat, Jan 22, 2011 at 9:57 AM, Josh Suereth <[hidden email]> wrote:
Why must you tell me I'm wrong when I say 'this surprised me'.  It's a notion of emotion on my own person.


Again, I urge you not to take this route. I told you no such thing, but there are technical points that argue that one should not be surprised that >mkdir is parsed as two tokens. Of course, one is free to be surprised about all sorts of things even though they are to be expected if one thinks about them a little bit.

-- Jim

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
In reply to this post by Daniel Sobral
I'll go back to my original point: How is 2>1 different? In both Lisp and Forth, that's a single token; in Scala and virtually every other "syntaxy" language, it's three tokens. One can pretty much bet that >mkdir is a single token iff 2>1 is a single token. Of course, one could always invent a language just to invalidate any such general assertion, or one can simply refer to one's mental states as if they trump all reason.

-- Jim

On Sat, Jan 22, 2011 at 2:09 PM, Daniel Sobral <[hidden email]> wrote:
Well, if the idea is provide examples to the contrary, >R is one of
Forth's standard words.

On Sat, Jan 22, 2011 at 15:40, Randall R Schulz <[hidden email]> wrote:
> On Saturday January 22 2011, Jim Balter wrote:
>> On Fri, Jan 21, 2011 at 7:30 AM, Josh Suereth
> <[hidden email]>wrote:
>> > Yes, I can understand that surprise coming from other languages.
>>
>> In almost all languages, >mkdir is two tokens, as it is in Scala. ...
>
> The Lisp family of languages deserves representation here, and it would
> not treat this as two tokens.
>
>
>> ...
>>
>> -- Jim
>
>
> Randall Schulz
>



--
Daniel C. Sobral

I travel to the future all the time.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: >mkdir

Jim Balter-2
In reply to this post by Josh Suereth



On Sat, Jan 22, 2011 at 2:23 PM, Josh Suereth <[hidden email]> wrote:

I agree that from a parsing/lexing perspective I think the idea that no space is required between operator tokens is valid.  However, the fact that there is no space required between an identifier and a method call would be surprising if you didn't see the concrete identifier as an operator (which I'd argue is a stretch).

Well, no space is required around the '.' Obviously a space is required next to the method call in amaxb, but that's not because it's a method call. We are used to not needing spaces next to parentheses, semicolons, or other non-alphanumerics, and none of that has anything to do with method calls. I certainly believe that some people are are surprised that spaces aren't needed between alphanumerics and non-alphanumerics in this case, but I do not believe that such surprise is well-founded -- that's *my* mental state.
 
 There's also the fact that some of the things I've read on scala imply that method names can be 'anything' whereas this is not true.

I noted quite a while ago that that *can't* be the case because, e.g., 2>1 is not a valid method name in Scala -- no one seems surprised about that when it is pointed out. Perhaps it wasn't an implication, but rather an unwarranted inference.
 
 I believe this helps propogate the myth that spaces are needed, because of the assumption that this would be the only way to split up identifiers.

I don't think there is such a "myth", but apparently some people do suffer from this clearly mistaken assumption.
 
In any case, if one does not know the identifier rules from the SLS (which I'd argue is quite a few people on this list) then the argument that these things should be intuitive with a little thinking is just absurd.

What is not absurd is that it pretty much follows from the fact that 2>1 is parsed as multiple tokens that >mkdir will also be parsed as multiple tokens and that Scala is just like other "syntaxy" languages, which is most of them, in that respect; one need not consult the SLS to recognize that.

-- Jim

 

On Sat, Jan 22, 2011 at 1:23 PM, Jim Balter <[hidden email]> wrote:

On Sat, Jan 22, 2011 at 9:57 AM, Josh Suereth <[hidden email]> wrote:
Why must you tell me I'm wrong when I say 'this surprised me'.  It's a notion of emotion on my own person.


Again, I urge you not to take this route. I told you no such thing, but there are technical points that argue that one should not be surprised that >mkdir is parsed as two tokens. Of course, one is free to be surprised about all sorts of things even though they are to be expected if one thinks about them a little bit.

-- Jim


12
Loading...