POV-Ray : Newsgroups : povray.off-topic : Why is Haskell interesting? : Re: Why is Haskell interesting? Server Time
4 Sep 2024 15:22:18 EDT (-0400)
  Re: Why is Haskell interesting?  
From: Nicolas Alvarez
Date: 30 Mar 2010 21:30:02
Message: <4bb2a59a@news.povray.org>
Darren New wrote:
>>> window["foo"] = Function(){...}
>> OK. So in what way does this mean that "functions are not first-class"?
> 
> I didn't say it did. I said that everything in Javascript is an object.

Correct, including functions themselves.

> There are no functions unassociated with a corresponding instance.

Functions are not associated with an instance when they are created, the 
"association" is at call time.

var f = function (x) { return x; };

What instance is f associated to?

If you call f(4), 'this' inside the function body will be the global object 
because of the way you *called* it. However:

var o = {};
o.f = f;
o.f(4);

This time, 'this' inside the function will be set to 'o'.

You can also do this:

var o = {};
f.call(o, 4);


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.