HighDots Forums  

Re: Partial evaluation in JavaScript

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Partial evaluation in JavaScript in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Erwin Moller
 
Posts: n/a

Default Re: Partial evaluation in JavaScript - 09-29-2008 , 09:52 AM







Karl Tikjøb Krukow schreef:
Quote:
I recently started playing with the idea of writing a partial evaluator
for JavaScript in JavaScript. I have tried to build a minimal
proof-of-concept by extending Crockford's Pratt parser for 'simplified'
JavaScript [1].

The current (very experimental) version extends Function.prototype with
a specialize function so e.g.,

var mk_tag = function(tag,clz,cont) {
return "<"+tag+" class='"+clz+"'>"+cont+"</"+tag+">";
};

var mk_div_green = mk_tag.specialize({tag:'div', clz: 'green'});

mk_div_green("Pratt rocks!");
//result: <div class='green'>Pratt rocks!</div


I've started an open source project, Jeene [2], and I thought you
hardcore JavaScripters might be interested. There are some portability
issues, e.g., it depends on Function.prototype.toString to obtain a
parseable representation of a function. A problem here is that
ECMAScript 3 says that the result of toString is "implementation
dependent". I am hoping for project Harmony to strengthen the contract
on toString, but I don't feel sure that will happen ;-)

Anyway, hope to have triggered some interest!

Hi Karl,

I checked your site: http://code.google.com/p/jeene/
It is not clear to me what it is you are building.
I do not want to lessen your enthousiasm, but what is the point of the
project?
If somebody needs to make a div, that is easy enough in JavaScript (and
HTML).
If you need to change an existing span/div to a certain class: that is
easy too.

Where does JEENE[2] come into the picture?
What is it excactly you want to build??

Regards,
Erwin Moller

--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================


Reply With Quote
  #2  
Old   
Erwin Moller
 
Posts: n/a

Default Re: Partial evaluation in JavaScript - 09-30-2008 , 05:10 AM







Karl Tikjøb Krukow schreef:
Quote:
Erwin Moller wrote:


Hi Karl,

I checked your site: http://code.google.com/p/jeene/
It is not clear to me what it is you are building.
I do not want to lessen your enthousiasm, but what is the point of the
project?

Don't worry other people have already done that ;-)
Ah good.
I hate being negative when somebody starts with a new initiative.

Quote:
The point of the project is to build a program specializer (= partial
evaluator). In the case of Jeene, a program specializer takes as input a
general function of several parameters and produces a specialized
function of fewer parameters by fixing the values of some of the
parameters. The point being that the specialized function is often much
more efficient.


The HTML tag was just an example to illustrate the flexibility and
efficiency aspects.

Was that helpful?
Partial. ;-)

Could you give us a more real life example where Jeene could be helpful?
I already told you why your earlier example was little convincing (for me).

Regards,
Erwin Moller


--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================


Reply With Quote
  #3  
Old   
Luke Yan
 
Posts: n/a

Default Re: Partial evaluation in JavaScript - 10-01-2008 , 06:04 AM



I guess what Karl plans to implement is something like Default
Arguements in C++ and PHP.

for example, we have this base method at first:
function baseMethod(arg1, arg2){
alert("This is a base method with arg2 is " + arg2);
}

now, if I invoke it like this:
baseMethod("value of arg1");
it will popup "This is a base method with arg2 is undefined" (in IE).

as for Karl's solution, now i can create another "extend" method:
var extendMethod = baseMethod.specialize({arg2: "default value of
arg2"});

then, invoke
extendMethod("value of arg1");
the popup msg becomes "This is a base method with arg2 is default
value of arg2".

But at least now, i didnot see large valuable thing in it.
maybe i've missed something, please correct me, karl

thanks
luke

Erwin Moller wrote:
Quote:
Karl Tikj�b Krukow schreef:
Erwin Moller wrote:


Hi Karl,

I checked your site: http://code.google.com/p/jeene/
It is not clear to me what it is you are building.
I do not want to lessen your enthousiasm, but what is the point of the
project?

Don't worry other people have already done that ;-)

Ah good.
I hate being negative when somebody starts with a new initiative.


The point of the project is to build a program specializer (= partial
evaluator). In the case of Jeene, a program specializer takes as input a
general function of several parameters and produces a specialized
function of fewer parameters by fixing the values of some of the
parameters. The point being that the specialized function is often much
more efficient.


The HTML tag was just an example to illustrate the flexibility and
efficiency aspects.

Was that helpful?

Partial. ;-)

Could you give us a more real life example where Jeene could be helpful?
I already told you why your earlier example was little convincing (for me).

Regards,
Erwin Moller


--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.