[Beanshell-dev] Support for operator overloading

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Beanshell-dev] Support for operator overloading

Joao Victor
Hi all,

Does anybody know if there has been any work, or plan, to make
Beanshell support operator overloading?

Because i was thinking about adding that support (would be very useful
for this project i'm working on), but i don't want to reinvent the
wheel.

Cheers,
J.V.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

RE: [Beanshell-dev] Support for operator overloading

Stevenson, Scott W
Yes!  I vote for operator overloading too!  I keep eyeing Groovy because
it has this feature.

Scott...

-----Original Message-----
From: Joao Victor [mailto:[hidden email]]
Sent: Sunday, November 27, 2005 10:12 AM
To: [hidden email]
Subject: [Beanshell-dev] Support for operator overloading

Hi all,

Does anybody know if there has been any work, or plan, to make Beanshell
support operator overloading?

Because i was thinking about adding that support (would be very useful
for this project i'm working on), but i don't want to reinvent the
wheel.

Cheers,
J.V.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems?  Stop!  Download the new AJAX search engine that
makes searching your log files as easy as surfing the  web.  DOWNLOAD
SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

RE: [Beanshell-dev] Support for operator overloading

Alexey Zinger
Ah, yes.  The great Java scripting holy war is here again...

--- "Stevenson, Scott W" <[hidden email]> wrote:

> Yes!  I vote for operator overloading too!  I keep eyeing Groovy because
> it has this feature.
>
> Scott...
>
> -----Original Message-----
> From: Joao Victor [mailto:[hidden email]]
> Sent: Sunday, November 27, 2005 10:12 AM
> To: [hidden email]
> Subject: [Beanshell-dev] Support for operator overloading
>
> Hi all,
>
> Does anybody know if there has been any work, or plan, to make Beanshell
> support operator overloading?
>
> Because i was thinking about adding that support (would be very useful
> for this project i'm working on), but i don't want to reinvent the
> wheel.
>
> Cheers,
> J.V.
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files for problems?  Stop!  Download the new AJAX search engine that
> makes searching your log files as easy as surfing the  web.  DOWNLOAD
> SPLUNK!
> <a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> <a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net


       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

RE: Support for operator overloading

Yemi I. D. Bedu
In reply to this post by Joao Victor
Hello,
Would you like the over loading to be scoped? What about allowing you to
alias a syntax symbol to a method call. Something like (each pair
exclusive syntax form):

// array1 + array2
Alias infix + MyArray.combine(#1, #2);
Alias : mapin #1 + #2 : mapout MyArray.combine(#1, #2);

// % s1 s2 s3
Alias postfix : start % : count 3
StringBuffer.append(#1).append(#2).append(#3);
Alias : mapin % #1 #2 #3 : mapout
StringBuffer.append(#1).append(#2).append(#3);

// MyArray[key1]
Alias wrap : start [ : end ] : inner 1 #1.getValue(#2);
Alias : mapin #1[#2] : mapout #1.getValue(#2);

// MyArray[key1]= value1
Alias wrap : start [ : end ]= : inner 1 : outer 1 MyArray.setValue(#1,
#2);
Alias : mapin #1[#2]= #3 : mapout #1.setValue(#2, #3);

Should the alias only take affect if the objects match the signature and
arguement type? Is it time that we move towards having a clean and
simple macro system? Those who would want more sugar can have it at any
time. And if some syntax is a fad, it just won't be adopted by the
community.

Yemi Bedu

P&R Fasteners
325 Pierce St
Somerset, NJ 08873
732-302-3600

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
Joao Victor
Sent: Sunday, November 27, 2005 11:12 AM
To: [hidden email]
Subject: [Beanshell-dev] Support for operator overloading

Hi all,

Does anybody know if there has been any work, or plan, to make Beanshell
support operator overloading?

Because i was thinking about adding that support (would be very useful
for this project i'm working on), but i don't want to reinvent the
wheel.

Cheers,
J.V.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems?  Stop!  Download the new AJAX search engine that
makes searching your log files as easy as surfing the  web.  DOWNLOAD
SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

RE: Support for operator overloading

Yemi I. D. Bedu
In reply to this post by Joao Victor
Hello,
 Even though they may hold some differences, I think there is a tie
between this and the dialects disscusion in February.
http://beanshell.org/BeanShellDialects.html
When I think about all this, I see that dialect as being extreme sugar.
Operator overloading would be a mild example of what is possible. It
still seems clumsy in that op-ov would want there to be inline embedding
and the dialect version, by past emails, would be a wrap (syntax
overhead) for the calls. That is why I mentioned the alias type of
syntax, so you can change meaning of symbols within a scope. Good day.


Yemi Bedu

P&R Fasteners
325 Pierce St
Somerset, NJ 08873
732-302-3600

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
Joao Victor
Sent: Sunday, November 27, 2005 11:12 AM
To: [hidden email]
Subject: [Beanshell-dev] Support for operator overloading

Hi all,

Does anybody know if there has been any work, or plan, to make Beanshell
support operator overloading?

Because i was thinking about adding that support (would be very useful
for this project i'm working on), but i don't want to reinvent the
wheel.

Cheers,
J.V.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems?  Stop!  Download the new AJAX search engine that
makes searching your log files as easy as surfing the  web.  DOWNLOAD
SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

RE: Support for operator overloading

Yemi I. D. Bedu
In reply to this post by Joao Victor
Hello,
I thought of a third syntax format:
Alias.map("#1 + #2", "MyArray.combine(#1, #2)");
Alias.map("% #1 #2 #3",
"StringBuffer.append(#1).append(#2).append(#3)");
Alias.map("#1[#2]", "#1.getValue(#2)");
Alias.map("#1[#2]= #3", "#1.setValue(#2, #3)")

We can then use the Alias as a scope executor:
Alias.setRemoteSyntax("t = newArray(); a = t['s']; t['b'] = 'c';");
Alias.getRemoteSyntax(); // -> "t = newArray(); a = t['s']; t['b'] =
'c';"
Alias.getLocalSyntax(); // -> "t = newArray(); a = t.getValue('s');
t.setValue('b', 'c');"
Alias.execute();

If Beanshell had an initial alias, you can then use all this:
currentAlias = This.getAlias();
currentAlias.map("#1 + #2", "(#1 instanceof myArray && #2 instanceof
myArray)? #1.add(#2) : #1 + #2");
There is the infinite loop call issue, but that might be solvable by
allowing the choice of aliasing to drop off on first fails. This would
mean that if you have a succesfull translation, it would loop to the
same line, but a fail would go to any of the remaining matching aliases.
Then you can chain the alais.

Or for this:
currentAlias.map("#1 + #2", "#1.add(#2)", "#1 instanceof myArray && #2
instanceof myArray");

It would a conditional alias. The shorter form would mean map(from, to,
true); though a little dangerous. Good day.

Yemi Bedu

P&R Fasteners
325 Pierce St
Somerset, NJ 08873
732-302-3600

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
Joao Victor
Sent: Sunday, November 27, 2005 11:12 AM
To: [hidden email]
Subject: [Beanshell-dev] Support for operator overloading

Hi all,

Does anybody know if there has been any work, or plan, to make Beanshell
support operator overloading?

Because i was thinking about adding that support (would be very useful
for this project i'm working on), but i don't want to reinvent the
wheel.

Cheers,
J.V.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files for problems?  Stop!  Download the new AJAX search engine that
makes searching your log files as easy as surfing the  web.  DOWNLOAD
SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Support for operator overloading

Joao Victor
I didn't mean to start a holy/flame war about the subject.

You could think "then use groovy", but Groovy doesn't work for me
because its runtime is too big. And i personally think operator
overloading is a very nice add-on scripts can give to the Java
language.

*Anyway*, i just asked it in the list because i didn't want to
reinvent the wheel. Since nobody said "i did it before", i started
doing it myself. I've already got some operators working.

Cheers,
J.V.



2005/11/28, Yemi D. Bedu <[hidden email]>:

> Hello,
> I thought of a third syntax format:
> Alias.map("#1 + #2", "MyArray.combine(#1, #2)");
> Alias.map("% #1 #2 #3",
> "StringBuffer.append(#1).append(#2).append(#3)");
> Alias.map("#1[#2]", "#1.getValue(#2)");
> Alias.map("#1[#2]= #3", "#1.setValue(#2, #3)")
>
> We can then use the Alias as a scope executor:
> Alias.setRemoteSyntax("t = newArray(); a = t['s']; t['b'] = 'c';");
> Alias.getRemoteSyntax(); // -> "t = newArray(); a = t['s']; t['b'] =
> 'c';"
> Alias.getLocalSyntax(); // -> "t = newArray(); a = t.getValue('s');
> t.setValue('b', 'c');"
> Alias.execute();
>
> If Beanshell had an initial alias, you can then use all this:
> currentAlias = This.getAlias();
> currentAlias.map("#1 + #2", "(#1 instanceof myArray && #2 instanceof
> myArray)? #1.add(#2) : #1 + #2");
> There is the infinite loop call issue, but that might be solvable by
> allowing the choice of aliasing to drop off on first fails. This would
> mean that if you have a succesfull translation, it would loop to the
> same line, but a fail would go to any of the remaining matching aliases.
> Then you can chain the alais.
>
> Or for this:
> currentAlias.map("#1 + #2", "#1.add(#2)", "#1 instanceof myArray && #2
> instanceof myArray");
>
> It would a conditional alias. The shorter form would mean map(from, to,
> true); though a little dangerous. Good day.
>
> Yemi Bedu
>
> P&R Fasteners
> 325 Pierce St
> Somerset, NJ 08873
> 732-302-3600
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Joao Victor
> Sent: Sunday, November 27, 2005 11:12 AM
> To: [hidden email]
> Subject: [Beanshell-dev] Support for operator overloading
>
> Hi all,
>
> Does anybody know if there has been any work, or plan, to make Beanshell
> support operator overloading?
>
> Because i was thinking about adding that support (would be very useful
> for this project i'm working on), but i don't want to reinvent the
> wheel.
>
> Cheers,
> J.V.
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files for problems?  Stop!  Download the new AJAX search engine that
> makes searching your log files as easy as surfing the  web.  DOWNLOAD
> SPLUNK!
> <a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick">http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
> _______________________________________________
> Beanshell-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-developers
>
>


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers