You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to loop...@googlegroups.com
I want to change static calls into Java to be a lot simpler:
`java.lang.System`.currentTimeMillis()
to:
require `java.lang.System`
System.currentTimeMillis()
or, with a special static scoping operator:
require `java.lang.System`
System::currentTimeMillis()
So it's clear that a Java static method is being called.
Dave Newton
unread,
Aug 13, 2012, 6:30:27 PM8/13/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to loop...@googlegroups.com
My 0.02USD; I tend towards the `::` operator as per JRuby; IMO it reduces ambiguity.
Related, but perhaps less palatable, I like being able to alias imports, although it does mean there's another mental step when figuring out what's being called unless you're paying attention. I.e., "require `java.lang.System` as `Sys`" or something. It's more useful for long, domain-specific imports, obviously, especially in scripts.
Definitely nice to skip the (what I consider) visually-awkward backticks, though.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to loop...@googlegroups.com
Hmm, yea I tend to agree about the :: (which is actually C++'s static scoping operator really). We can alias Loop imports already using the 'as' clause--but I'm not convinced aliasing Java imports is a good thing--someone reading the code for the first time may not have any idea what's going on?
Maybe it's not an issue as they can look at the require block. Yea definitely want to get rid of the backticks as much as possible, it introduces complexity into the parser though, that's why I had them originally.
Dave Newton
unread,
Aug 13, 2012, 6:54:58 PM8/13/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to loop...@googlegroups.com
On Mon, Aug 13, 2012 at 6:36 PM, Dhanji R. Prasanna wrote:
Maybe it's not an issue as they can look at the require block. Yea definitely want to get rid of the backticks as much as possible, it introduces complexity into the parser though, that's why I had them originally.
I haven't found it to be a huge issue in real life, and in code where it might be, I just don't use it.
In JRuby I use something similar (including a Java package in a module) a lot to reduce noise in scripts or when interacting with systems via a REPL. It's one of those things that can lead to horrific abuse, but is also pretty nice when used in small doses.
Dave
--
Dhanji R. Prasanna
unread,
Aug 18, 2012, 2:50:45 AM8/18/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to loop...@googlegroups.com
These changes are now live in trunk (not yet in release build):
require java.lang.System
main ->
System::println('hello')
The parser will support aliases for java types but this doesn't actually work yet.
The old scheme with backticks continues to work and is useful for edge cases like class names beginning with a lower case (the Loop grammar only recognizes types in CamelCase).
You can also use backticks if you want to use a FQN inline.