RE: Support for operator overloading
"Yemi D. Bedu" <yemi-DnQzskBZRmpWk0Htik3J/[email protected]> Mon, 28 Nov 2005 14:38:03 -0500
| Newsgroups | gmane.comp.java.beanshell.devel |
|---|---|
| Message-ID | <[email protected]> |
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: beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:beanshell-developers-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of
Joao Victor
Sent: Sunday, November 27, 2005 11:12 AM
To: beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
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!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=ick
_______________________________________________
Beanshell-developers mailing list
Beanshell-developers-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
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!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click