[Yhc] YCR2JS and Safari

Dimitry Golubovsky golubovsky at gmail.com
Mon Nov 13 15:16:26 EST 2006


Neil, Malcolm,

On 11/13/06, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi Dimitry,
>
> > > This demo page appears totally blank to me.  (Using Safari under MacOS
X
> > > 10.4.8).  The Javascript console tells me there was a "Type Error line
1".
> >
> > I also received a message about some weird error in Opera.
>
> Under Opera its also blank to me (but an old version definately worked)
>
> The problem seems to be with this line (2620):
>
> var StdOverlay_46_95LAMBDA450=new HSFun("StdOverlay._LAMBDA450", 0,
> function(){return new String("function(x,y){return (x - (x %
> y))/y;}(exprEval(a),exprEval(b));");});
>
> Where as far as I can see a and b are undefined?
>

What you see indeed should not be there, but I don't know how to get rid of
it.

There is the `unsafeJS' pseudo-function (indeed this is kind of a macro)
which takes a string literal as an argument. The converter detects such
function application and creates a wrapper which is used to call this code
from Haskell.

So, x % y occurs in two places:

var Prelude_46Prelude_46Integral_46Prelude_46Int_46quot=new HSFun("
Prelude.Prelude.Integral.Prelude.Int.quot", 2, function(v26142,
v26143){return function(x,y){return (x - (x %
y))/y;}(Number(exprEval(v26142)),Number(exprEval(v26143)));});

This is the inlining of the QUOT_W primitive.

var YHC_46Primitive_46primIntegerQuot=new HSFun("
YHC.Primitive.primIntegerQuot", 2, function(a, b){
function(x,y){return (x - (x % y))/y;}(exprEval(a),exprEval(b));});

Color code:

body wrapper

This comes from the Overlay:

global_YHC'_Primitive'_primIntegerQuot a b = unsafeJS
  "function(x,y){return (x - (x % y))/y;}(exprEval(a),exprEval(b));"

In this function, you may see that a and b are formal arguments. The
anonymous function is applied to them (after each one is forced to
evaluate).

What you refer to, LAMBDA450, is used for the second declaration. It was an
argument to unsafeJS. What it contains inside is just a string literal, and
if Safari is trying to interpret it as a code to execute, this is not a
right thing.

I also received a weird error report about Opera (also involving
function(x,y)). I am going to ask at both browsers' forums. Maybe someone
will be able to explain these problems.

This runs w/o problems in Netscape, FireFox, and MSIE.

-- 
Dimitry Golubovsky

Anywhere on the Web
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/yhc/attachments/20061113/71c9ecf0/attachment.htm


More information about the Yhc mailing list