Does Beanshell Support Numeric Literals with Underscores?

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

Does Beanshell Support Numeric Literals with Underscores?

Edward Wong
I apologize in advance if this isn't the right place to email this question. I'm trying to write some scripts in which I use binary values along with underscores to make it easier to read.

For Example:

int BIT_MASK = 0b1000_1111;

However when I try running this, I get an error that looks like this:

*** User input parse error at line 1, column 17.  Encountered: b1000_1111

Is it correct that "Numeric Literals with Underscores" isn't supported in Beanshell? Are there any plans to make it work?

~ Edward Wong
------------------------------------------------------------------------------
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does Beanshell Support Numeric Literals with Underscores?

Daniel Martin-7
Not only do underscores in numeric literals not work in beanshell, binary literals (literals beginning with "0b") don't work either!

When I had to store constants in binary in beanshell or java, I tended to use Integer.parseInt("01001100", 2)

In general, the syntax beanshell supports is approximately that of java 1.4, with a few allowed variances.

Beanshell hasn't change in nearly a decade; many people believe it was effectively abandoned by its creator.

There were some attempts to revive development in a "Beanshell 2.0" project, but so far as I know that never achieved much adoption.

> On Jun 10, 2015, at 4:39 PM, Edward Wong <[hidden email]> wrote:
>
> I apologize in advance if this isn't the right place to email this question. I'm trying to write some scripts in which I use binary values along with underscores to make it easier to read.
>
> For Example:
>
> int BIT_MASK = 0b1000_1111;
>
> However when I try running this, I get an error that looks like this:
>
> *** User input parse error at line 1, column 17.  Encountered: b1000_1111
>
> Is it correct that "Numeric Literals with Underscores" isn't supported in Beanshell? Are there any plans to make it work?
>
> ~ Edward Wong
> ------------------------------------------------------------------------------
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>

------------------------------------------------------------------------------
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does Beanshell Support Numeric Literals with Underscores?

Alexey Zinger
In reply to this post by Edward Wong
I did not know you could do that in Java until your email :)  My
understanding is that Bean Shell was written using an old pre-Java 5
grammar, so binary integers and underscores are not supported.  This
particular project is in limbo, but there is at least one Bean Shell
fork you may want to check out for latest developments:
https://code.google.com/p/beanshell2/

On 2015-06-10 16:39, Edward Wong wrote:

> I apologize in advance if this isn't the right place to email this question. I'm trying to write some scripts in which I use binary values along with underscores to make it easier to read.
>
> For Example:
>
> int BIT_MASK = 0b1000_1111;
>
> However when I try running this, I get an error that looks like this:
>
> *** User input parse error at line 1, column 17.  Encountered: b1000_1111
>
> Is it correct that "Numeric Literals with Underscores" isn't supported in Beanshell? Are there any plans to make it work?
>
> ~ Edward Wong
> ------------------------------------------------------------------------------
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users

------------------------------------------------------------------------------
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does Beanshell Support Numeric Literals with Underscores?

David Lee
In reply to this post by Daniel Martin-7
"Beanshell 2.0" is alive and well - as for 'adoption' - who knows - how much was beanshell 1x adopted ?
Atleast the code is on github, the work is primarily bug fixes and there are a few active contributors - me being one
(click click) - hmm looks like the last update was last year -
thats not bad in itself for what is otherwise a mature product ... but its on google code which is EOL
https://code.google.com/p/beanshell2/

Looking on Github I found a dozen clones - none of which had the latest update from google or maintained the commiters  - so to make maters worse I just cloned it myself to

https://github.com/DALDEI/beanshell2

I personally use beanshell2 (was beanshell) on several commercial and personal projects - it works now as good as it ever did .... ( java 1.4 + special features that are similar to what we just got in 1.8 but not the same -  )

But I doubt its going to go further.
So many other JVM and Java-Like languages have gone so much further, and the original author has been unheard from for a decade (anyplace I can find atleast) - so the motivation to keep working on beanshell seems to be current users applying bug fixes or minor updates.






----------------------------------------
David A. Lee
[hidden email]
http://www.xmlsh.org

-----Original Message-----
From: Daniel Martin [mailto:[hidden email]]
Sent: Wednesday, June 10, 2015 6:16 PM
To: [hidden email]
Subject: Re: [Beanshell-users] Does Beanshell Support Numeric Literals with Underscores?

Not only do underscores in numeric literals not work in beanshell, binary literals (literals beginning with "0b") don't work either!

When I had to store constants in binary in beanshell or java, I tended to use Integer.parseInt("01001100", 2)

In general, the syntax beanshell supports is approximately that of java 1.4, with a few allowed variances.

Beanshell hasn't change in nearly a decade; many people believe it was effectively abandoned by its creator.

There were some attempts to revive development in a "Beanshell 2.0" project, but so far as I know that never achieved much adoption.

> On Jun 10, 2015, at 4:39 PM, Edward Wong <[hidden email]> wrote:
>
> I apologize in advance if this isn't the right place to email this question. I'm trying to write some scripts in which I use binary values along with underscores to make it easier to read.
>
> For Example:
>
> int BIT_MASK = 0b1000_1111;
>
> However when I try running this, I get an error that looks like this:
>
> *** User input parse error at line 1, column 17.  Encountered:
> b1000_1111
>
> Is it correct that "Numeric Literals with Underscores" isn't supported in Beanshell? Are there any plans to make it work?
>
> ~ Edward Wong
> ----------------------------------------------------------------------
> -------- _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>

------------------------------------------------------------------------------
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users

------------------------------------------------------------------------------
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Loading...