By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,808 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Javascript Namespace

P: n/a
Hello,

How to create a namespace in Javascript containing two methods?
And how to access those methods?

Thanks,
Miguel
Jun 27 '08 #1

✓ answered by RoLo

On Jun 18, 9:04*pm, shapper <mdmo...@gmail.comwrote:
Hello,
>
How to create a namespace in Javascript containing two methods?
And how to access those methods?
>
Thanks,
Miguel
you mean this:

Expand|Select|Wrap|Line Numbers
  1. var name={
  2. method1:function(){alert(1);},
  3. method2:function(){alert(2);}
  4. };
  5.  
  6. name.method1();
  7. name.method2();

Share this Question
Share on Google+
20 Replies


P: n/a
On Jun 19, 11:04 am, shapper <mdmo...@gmail.comwrote:
Hello,

How to create a namespace in Javascript
I presume you don't really mean XML namespace. :-)

The term "namespace" in javascript is sometimes (probably erroneously)
used to describe a design pattern where functions are added as
properties of a single object rather than as global functions.

containing two methods?
Sounds a lot like homework to me. Create an object, add two
properties, assign them references to functions.

And how to access those methods?
The same way you access any object properties, use either dot or
square bracket notation as appropriate.

Have a go, post the result and (almost certainly) you'll get
constructive criticism.
--
Rob
Jun 27 '08 #2

P: n/a
On Jun 18, 9:04*pm, shapper <mdmo...@gmail.comwrote:
Hello,

How to create a namespace in Javascript containing two methods?
And how to access those methods?

Thanks,
Miguel
you mean this:

Expand|Select|Wrap|Line Numbers
  1. var name={
  2. method1:function(){alert(1);},
  3. method2:function(){alert(2);}
  4. };
  5.  
  6. name.method1();
  7. name.method2();
Jun 27 '08 #3

P: n/a
RobG wrote:
On Jun 19, 11:04 am, shapper <mdmo...@gmail.comwrote:
>How to create a namespace in Javascript

I presume you don't really mean XML namespace. :-)

The term "namespace" in javascript is sometimes (probably erroneously)
used to describe a design pattern where functions are added as
properties of a single object rather than as global functions.
So-called "global functions" are in fact methods of the Global Object, a
single object at that. Your statement is only beginning to make sense if
you say "single *user-defined* object" instead.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #4

P: n/a
On Jun 18, 6:04 pm, shapper <mdmo...@gmail.comwrote:
Hello,

How to create a namespace in Javascript containing two methods?
And how to access those methods?
RoLo's answer may have been what you were seeking.

I recently blabbed on and on about this on my blog

http://peter.michaux.ca/article/7944

Many of the things I wrote about have been discussed on this group.

Peter
Jun 27 '08 #5

P: n/a
Thomas 'PointedEars' Lahn wrote on 22 jun 2008 in comp.lang.javascript:
So-called "global functions" are in fact methods of the Global Object, a
single object at that. Your statement is only beginning to make sense if
you say "single *user-defined* object" instead.
It would be beter to say "default object", or better "root default object",
rather than "global object", since this default is not a default
everywhere, but only where the local scope has no other default defined,
as it must be in the root.

[Global, in my view means everywhere, so also in local places.]

It is no matter whether a variable or an object is ment, as it is only the
named pointer that is affected. Only I do not think it is possible to
define a local scope for the default object?

Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2.  
  3. var obj = {};
  4.  
  5. window.a = function(){alert('default-a')};
  6. obj.a = function() {alert('obj-a')};
  7.  
  8. a();
  9. window.a();
  10. obj.a();
  11.  
  12. </script>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #6

P: n/a
Evertjan wrote:
Thomas 'PointedEars' Lahn wrote on 22 jun 2008 in
comp.lang.javascript:
>So-called "global functions" are in fact methods of the
Global Object, a single object at that. Your statement
is only beginning to make sense if you say "single
*user-defined* object" instead.

It would be beter to say "default object", or better "root
default object", rather than "global object", since this
default is not a default everywhere, but only where the
local scope has no other default defined, as it must be in
the root.
I don't see that as better. It is getting pretty VKesque; I cannot tell
what you are talking about by reading the words.
[Global, in my view means everywhere, so also in local places.]
The global object is at the end of every scope chain, and so it is
everywhere (at least in some sense).
It is no matter whether a variable or an object is ment, as it
is only the named pointer that is affected. Only I do not think
it is possible to define a local scope for the default object?
<snip>

What do you mean by "default object " here? Is it the object used as the
'base' of the resulting Reference type when Identifier resolution fails
to find a corresponding property name on any object on the scope chain?
That would be the object labelled as "the global object" by the
language's specification.

Richard.

Jun 27 '08 #7

P: n/a
On Jun 23, 3:34 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
RobG wrote:
On Jun 19, 11:04 am, shapper <mdmo...@gmail.comwrote:
How to create a namespace in Javascript
I presume you don't really mean XML namespace. :-)
The term "namespace" in javascript is sometimes (probably erroneously)
used to describe a design pattern where functions are added as
properties of a single object rather than as global functions.

So-called "global functions" are in fact methods of the Global Object, a
single object at that. Your statement is only beginning to make sense if
you say "single *user-defined* object" instead.
The phrase "rather than" infers some other object than the global
object. I'm sorry if it is ambiguous.

The name space object could be any object other than the global
object, be it native or host. It need not be a user-defined native
object, though I would expect it to be.
--
Rob
Jun 27 '08 #8

P: n/a
Richard Cornford wrote on 23 jun 2008 in comp.lang.javascript:
Evertjan wrote:
>Thomas 'PointedEars' Lahn wrote on 22 jun 2008 in
comp.lang.javascript:
>>So-called "global functions" are in fact methods of the
Global Object, a single object at that. Your statement
is only beginning to make sense if you say "single
*user-defined* object" instead.

It would be beter to say "default object", or better "root
default object", rather than "global object", since this
default is not a default everywhere, but only where the
local scope has no other default defined, as it must be in
the root.

I don't see that as better. It is getting pretty VKesque; I cannot
tell what you are talking about by reading the words.
I'm sorry.
>[Global, in my view means everywhere, so also in local places.]

The global object is at the end of every scope chain, and so it is
everywhere (at least in some sense).
Now you are just repeating the definition I just pointed to as wrong.
>It is no matter whether a variable or an object is ment, as it
is only the named pointer that is affected. Only I do not think
it is possible to define a local scope for the default object?
<snip>

What do you mean by "default object " here? Is it the object used as
the 'base' of the resulting Reference type when Identifier resolution
fails to find a corresponding property name on any object on the scope
chain?
Now I cannot tell what you are talking about by reading the words.
I think you are saying the same as I did in a complicated way.

The default object is just the object that is "assumed" if no definite
object is specified.

So:

window.myThing

points to the same variable/function/whatever as:

myThing

unless the local default object is specified otherwize.

So methods and values can have a default objects, while objects, methods
and values can have a default action/method/etc.

I do not think that that is completely implemented in JS, but that is a
nice goal for object oriented "namespace naming".
That would be the object labelled as "the global object" by the
language's specification.
Sure, but I object to the word "global" in such specification, as
"global" means everywhere, and not "everywhere unless"

In the above it just means "default" or "root", if the name space system
is seen as a tree. If it is internally a tree does [to me] not matter to
the naming.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #9

P: n/a
"Evertjan." <ex**************@interxnl.netwrites:
Thomas 'PointedEars' Lahn wrote on 22 jun 2008 in comp.lang.javascript:
>So-called "global functions" are in fact methods of the Global Object, a
single object at that. Your statement is only beginning to make sense if
you say "single *user-defined* object" instead.

It would be beter to say "default object", or better "root default object",
rather than "global object", since this default is not a default
everywhere,
Default what?
but only where the local scope has no other default defined,
as it must be in the root.
As it must be *what* in the root?
[Global, in my view means everywhere, so also in local places.]
The global object is an object, no matter where you are. There must
be some property of this object that you think is not globally applicable.
It is no matter whether a variable or an object is ment, as it is only the
named pointer that is affected. Only I do not think it is possible to
define a local scope for the default object?
I just don't understand this. Try to explain it with more words.
(E.g., do you mean by "default object" what was previously in the thread
called "global object"?)

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #10

P: n/a
Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javascript:
"Evertjan." <ex**************@interxnl.netwrites:
>Thomas 'PointedEars' Lahn wrote on 22 jun 2008 in
comp.lang.javascript:
>>So-called "global functions" are in fact methods of the Global
Object, a single object at that. Your statement is only beginning
to make sense if you say "single *user-defined* object" instead.

It would be beter to say "default object", or better "root default
object", rather than "global object", since this default is not a
default everywhere,

Default what?
As I wrote in the parallel? posting:

The default object is just the object that is "assumed" if no definite
object is specified.

.... when calling that object in the script.

So, in browser js:

window.myValue is the same as myValue,
unless in a subscope myValue is redefined
[= has a pointer to another object/property/method]

It would be nice of each subscope could be given a named default subroot
object, because now only the myValue of the root scope's and the present
scope's myValue are callable, not the in-between-scope's myValue-s.
>but only where the local scope has no other default defined,
as it must be in the root.

As it must be *what* in the root?
Object. [the default word in this sentence ;-)]
The same however is true for all defaulting.

>[Global, in my view means everywhere, so also in local places.]

The global object is an object, no matter where you are.
Yes, just like any other object, but that's why naming that "global" is not
right. It is the root object of the root scope.

Theoretically you could set another object as the default object in the
root, so that the original root object is no longer the default.
[Perhaps not possible in present day JS, but that is only implementation.]

Seen as a tree, you could call the object the "global root object",
but why shorten that to "global object"? Beter shorten that to "the root
object"

Even the naming pointer to this object can be overwritten to mean another
object, either in the root scope or any other scope. This could make the
global root object effectively unreachable in that scope.
There must
be some property of this object that you think is not globally
applicable.
Why? If that is true the same must go for all other objects in the root
scope. But this is not about properties or methods, but about the object
itself.

Objects are only accessable in JS by their naming pointer. different scopes
can use the same name for different objects.

In the same sense there are no local objects, just local names pointing to
objects.

If an object is defined in a local scope, however, it would at present be
difficult to export the use of such object to another scope that is not a
"subscope" of that scope, just because there is no way to move the pointer
to that other scope.
>It is no matter whether a variable or an object is ment, as it is
only the named pointer that is affected. Only I do not think it is
possible to define a local scope for the default object?

I just don't understand this. Try to explain it with more words.
(E.g., do you mean by "default object" what was previously in the
thread called "global object"?)
No, the default object is the object that does not have to be named in that
scope. Perhaps I used that where I ment to say the root object. In JS, it
usualy is the same object, but that is implementation.

I just object to using the word global here for the root object,
becaus it gives the wrong idea, that it is the only object available in all
[sub]scopes. All other objects of [= defined in] the root scope have the
same possibilities, as long as the name is not reused.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #11

P: n/a
"Evertjan." <ex**************@interxnl.netwrites:
Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javascript:
>Default what?

As I wrote in the parallel? posting:

The default object is just the object that is "assumed" if no definite
object is specified.

... when calling that object in the script.

So, in browser js:

window.myValue is the same as myValue,
unless in a subscope myValue is redefined
[= has a pointer to another object/property/method]
The expression "myValue" is a variable expression. It resolves the
variable wrt. the current scope. In Javascript it is a lexical scope.
If no variable with that name exists in the scope, then Javascript
considers the variable to be a global variable. Global variables
are properties of the global object.

And "window.myValue" is a property lookup on the global object, if
"window" resolves to a reference to the global object.

As I read your explanation, it seems that you consider "myValue" as
being equivalent to "window.myValue" because it is equivalent to a
property lookup, with the global object as a "default object" where
"myValue" has no explicit object of the property.

I consider variable lookup and property lookup to be very different
processes. Naming an object that holds the global variables the
"global object" is perfectly reasonable to me, and calling it a
"default object" is misleading, because "myValue" is not treated
as a property lookup on a default object.
It would be nice of each subscope could be given a named default subroot
object, because now only the myValue of the root scope's and the present
scope's myValue are callable,
they are the only ones that can be accessed, yes.
not the in-between-scope's myValue-s.
Indeed. A lexical scope means that you can only access the closest
enclosing declaration of a given name. However, being lexically scoped,
whoever wrote it would have access to all the code of the scope, and
could rename one of the variables if the shadowing wasn't intentional.

Yes, just like any other object, but that's why naming that "global" is not
right. It is the root object of the root scope.
Technically the global object is not in the scope chain. It is
accessed only when the scope chain fails to resolve a variable
name. Effectively, though, it is almost as if the global object was
at the root of all scope chains.
Theoretically you could set another object as the default object in the
root, so that the original root object is no longer the default.
[Perhaps not possible in present day JS, but that is only implementation.]
Even in present day Javascript, if you access a function defined in another
page, it will have a different global object.
Seen as a tree, you could call the object the "global root object",
but why shorten that to "global object"? Beter shorten that to "the root
object"
It's a matter of intent, I guess. The global object holds the global
variables. A root object would be at the root of the scope chain.
The authors of Javascript had the former perspective.

Even the naming pointer to this object can be overwritten to mean another
object, either in the root scope or any other scope. This could make the
global root object effectively unreachable in that scope.
The property "window" of the global object can probably be changed, or
shadowed by a local variable. However the global object is always accessible,
e.g.,
var global = (function(){return this;})();

Objects are only accessable in JS by their naming pointer. different scopes
can use the same name for different objects.
Objects are passed around as references. Those references can be
stored in variables or object properties ("naming pointer"), but they
can also be the return value of a function.
In the same sense there are no local objects, just local names pointing to
objects.
There are no local objects. The only thing that is local (to a
function call) are local variables. That includes arguments
(also accessible as properties of the arguments object).
If an object is defined in a local scope, however, it would at present be
difficult to export the use of such object to another scope that is not a
"subscope" of that scope, just because there is no way to move the pointer
to that other scope.
There are two ways to have values exit a function call: store it in a
place that is also accessible outside the call (global variable or
local variable in an enclosing scope) or return it as the result
of the function. The latter requires no variables/names.
No, the default object is the object that does not have to be named in that
scope.
That's one view of what happens when you access a global variable.
However, that view is flawed as the expression "myVariable" is only
relative to the global object if it is not a local variable in scope.
It's not a property lookup where the target object "isn't named".
Perhaps I used that where I ment to say the root object. In JS, it
usualy is the same object, but that is implementation.
It's specification. The ECMAScript specification states that the
global object is where unresolved variables are finally attempted
resolved against. I.e., it's what you call the root object of scope
based variable resolution.
It is also the variables object of global code (code not inside a
function body).
I just object to using the word global here for the root object,
becaus it gives the wrong idea,
And I think it is the right idea.
that it is the only object available in all [sub]scopes.
That's not what "global object" means. But it is true that it is
accessible in all scopes. If a function is called directly, and not as
a method (referenced as "object.property"), then "this" refers to the
global object in the method body.
All other objects of [= defined in] the root scope have the
same possibilities, as long as the name is not reused.
Yes, that's just basic scope rules.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #12

P: n/a
On Jun 23, 4:52 pm, Lasse Reichstein Nielsen wrote:
Evertjan writes:
<snip>
>Yes, just like any other object, but that's why naming that
"global" is not right. It is the root object of the root scope.

Technically the global object is not in the scope chain. It is
accessed only when the scope chain fails to resolve a variable
name. Effectively, though, it is almost as if the global object was
at the root of all scope chains.
<snip>
ECMA 262:-
| 10.2 Entering An Execution Context
|
| ...
| 10.2.1 Global Code
|
| The scope chain is created and initialised to contain the global
| object and no others.
|
| Variable instantiation is performed using the global object as
| the variable object and using property attributes {DontDelete }.
|
| The this value is the global object.

So in the global execution context the scope chain consists of one
object; the global object.

| 13 Function Definition
| ...
| The production FunctionDeclaration :
| function Identifier ( FormalParameterListopt ) { FunctionBody }
| is processed for function declarations as follows:
|
| 1. Create a new Function object as specified in section 13.2 with
| parameters specified by FormalParameterList, and body specified
| by FunctionBody. Pass in the scope chain of the running execution
| context as the Scope.
| ...

Note the "Pass in the scope chain of the running execution context as
the Scope". The same step appears in all function creation algorithms
except for the - new Function -.

| 13.2 Creating Function Objects
| Given an optional parameter list specified by FormalParameterList, a
| body specified by FunctionBody, and a scope chain specified by
Scope,
| a Function object is constructed as follows:
|
| 1. If ...
| ...
| 19. Set the [[Scope]] property of F to a new scope chain (section
| 10.1.4) that contains the same objects as Scope.
| 20. Return F.

The "Scope" passed becomes the [[Scope]] of the new function object,
and then with a Variable object added becomes the scope of the
execution context when the function is executed, and so the "running
execution context" if any inner functions get created. Thus the global
object *is* at the end of all scope chains in javascript.
Jun 27 '08 #13

P: n/a
RobG wrote:
Thomas 'PointedEars' Lahn wrote:
>RobG wrote:
>>On Jun 19, 11:04 am, shapper <mdmo...@gmail.comwrote:
How to create a namespace in Javascript
I presume you don't really mean XML namespace. :-)
The term "namespace" in javascript is sometimes (probably erroneously)
used to describe a design pattern where functions are added as
properties of a single object rather than as global functions.
So-called "global functions" are in fact methods of the Global Object, a
single object at that. Your statement is only beginning to make sense if
you say "single *user-defined* object" instead.

[...]
The name space object could be any object other than the global
object, be it native or host. It need not be a user-defined native
object, though I would expect it to be.
With host objects, all bets are off.[tm]

So it should be a native object. Since the Global Object cannot be
considered (using it created the problem in the first place) and other
built-in objects do not allow arbitrary augmentation (consider built-in
properties with the ReadOnly attribute), it needs to be a user-defined object.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #14

P: n/a
Henry <rc*******@raindrop.co.ukwrites:
Thus the global object *is* at the end of all scope chains in
javascript.
Indeed, my bad.

Note to self: Check spec before presseing "send".
/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #15

P: n/a
Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javascript:
In Javascript it is a lexical scope.
Lasse, we are speaking in different worlds.

You are starting with what the original JS writing fathers or the ECMA
writers wanted it to be.

I am starting with what I would like to be a language of just objects
with it's properties and methods. An intellectual challenge.

All thsi started in this thread because Pointed put my Ears up on the
idea,
that a function must be nothing more or less than a method of an object,
usually the root object [my wording], and a variable a property of the
same. [while in fact they all thre are just pointers to those three, and
only those pointers 'have' scope limitations.]

The internal implementation, nor the primordial ideas of the writing
fathers come into play with my idealistic 'scope', where there is no
place for things like a "lexical" scope [what is that anyway?], and there
is no place to call anything global which is only the root of all
objects, as global is about scope, so only about pointers.

Probably even object hierarchy is only about pointers, I have to think
that through.

The present differences of use of object, object.method[function] and
object.property[variable] would be finished.

Defaulting would be only a matter of coding ease, not linked to any
internal substance but to scope limitations.

Oh what a wonderful objective Pointed pointer world it would be,
where not only the Ears, but the whole JS is "doing it with" pointers.

<http://www.audiobooksonline.com/media/1572701439.jpg>

;-)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #16

P: n/a
"Evertjan." <ex**************@interxnl.netwrites:
Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javascript:
>In Javascript it is a lexical scope.

Lasse, we are speaking in different worlds.

You are starting with what the original JS writing fathers or the ECMA
writers wanted it to be.

I am starting with what I would like to be a language of just objects
with it's properties and methods. An intellectual challenge.
We are indeed speaking about different things, if you are talking
about a hypothetical language that is similar, but not equivalent, to
Javascript.
All thsi started in this thread because Pointed put my Ears up on the
idea,
that a function must be nothing more or less than a method of an object,
usually the root object [my wording], and a variable a property of the
same. [while in fact they all thre are just pointers to those three, and
only those pointers 'have' scope limitations.]
PointedEars merely pointed out that a "global function" was already a
property of an object.
Not all functions are, in Javascript.
Take this expression:

Expand|Select|Wrap|Line Numbers
  1. alert( (function(y){return function(x){return y+x};})(24)(18) );
There are two functions here that are not properties of any object
at any time. The outer is just an anonymous function. The inner
is an anonymous function that even leaves its defining scope.

The internal implementation, nor the primordial ideas of the writing
fathers come into play with my idealistic 'scope', where there is no
place for things like a "lexical" scope [what is that anyway?],
A lexical scope is one where the association between variable declaration
and variable use is determined by the program syntax. A variable use
always refer to a variable declaration in a syntactically enclosing
block/scope.

Example:
Expand|Select|Wrap|Line Numbers
  1. function test(x) {
  2. var a = function(f,x) { return f(x); }
  3. return a(function(y){return x;}, 42);
  4. }
  5. alert(test(37));
This alerts 37. The "x" in "return x" refers to the argument of the
"t" function, even if the function containing the "return x" is
eventually called in the scope of another declaration of "x".

Syntactic scope is so natural to most programmers that they don't even
think of it. However, not all languages have syntactic scope. The
Common Lisp and Emacs Lisp languages has the "opposite": dynamic scope.
Example(in elisp):
Expand|Select|Wrap|Line Numbers
  1. (let ((test (lambda (x)
  2. (let ((a (lambda (f x) (funcall f x))))
  3. (funcall a (lambda (y) x) 37)))))
  4. (funcall test 42))
It is equivalent to the above Javascript program, but its result
is 37.
and there is no place to call anything global which is only the root
of all objects
Root of objects? Objects does not have to form any hierarchy. The
scope chains might, but if that is what you refer to, do call the
it "scope".
, as global is about scope, so only about pointers.
And I'm not sure what "pointers" mean here either.
Probably even object hierarchy is only about pointers, I have to think
that through.
Objects are referenced through references. Calling them pointers are
reasonable, although sometimes slightly misleading. But that means that
any object structure is connected through references, whether hierarchial
or not.
The present differences of use of object, object.method[function] and
object.property[variable] would be finished.
Is there a difference?

Personally, I'd much rather that they made the global object unreachable
through code, so the only way to create new variables is using the
"var" construction.
Accessing variables as properties of an object is so ... explicit.
It exposes what I consider an implementation detail: that an object
holds the variables. Most other languages do fine without that.

/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #17

P: n/a
Lasse Reichstein Nielsen <lr*@hotpop.comwrites:
Example(in elisp):
(let ((test (lambda (x)
(let ((a (lambda (f x) (funcall f x))))
(funcall a (lambda (y) x) 37)))))
(funcall test 42))

It is equivalent to the above Javascript program, but its result
is 37.
Which is the correct result, when you noticed that I managed to swap
37 and 42 in the program, compared to the Javascript example.
Oops.
The point stands, though :)
/L
--
Lasse Reichstein Nielsen
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jun 27 '08 #18

P: n/a
On Jun 23, 9:51 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
With host objects, all bets are off.[tm]
<URL:
http://tess2.uspto.gov/bin/showfield?f=toc&state=t9tfpi.1.1&p_search=searchss &p_L=50&BackReference=&p_plural=yes&p_s_PARA1=&p_t agrepl%7E%3A=PARA1%24LD&expr=PARA1+AND+PARA2&p_s_P ARA2=%22With+host+objects%2C+all+bets+are+off.%22& p_tagrepl%7E%3A=PARA2%24COMB&p_op_ALL=AND&a_defaul t=search&a_search=Submit+Query&a_search=Submit+Que ry>

Try for yourself

<URL: http://tess2.uspto.gov/bin/gate.exe?f=searchss&state=t9tfpi.1.1>

Peter
Jun 27 '08 #19

P: n/a
Peter Michaux wrote:
Thomas 'PointedEars' Lahn wrote:
>With host objects, all bets are off.[tm]

<URL:
http://tess2.uspto.gov/bin/showfield?f=toc&state=t9tfpi.1.1&p_search=searchss &p_L=50&BackReference=&p_plural=yes&p_s_PARA1=&p_t agrepl%7E%3A=PARA1%24LD&expr=PARA1+AND+PARA2&p_s_P ARA2=%22With+host+objects%2C+all+bets+are+off.%22& p_tagrepl%7E%3A=PARA2%24COMB&p_op_ALL=AND&a_defaul t=search&a_search=Submit+Query&a_search=Submit+Que ry>

Try for yourself
No, thanks.

<http://www.catb.org/~esr/jargon/html/0/TM.html>
<URL: http://tess2.uspto.gov/bin/gate.exe?f=searchss&state=t9tfpi.1.1>
404-compliant.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Jun 27 '08 #20

P: n/a
Lasse Reichstein Nielsen wrote on 24 jun 2008 in comp.lang.javascript:
We are indeed speaking about different things, if you are talking
about a hypothetical language that is similar, but not equivalent, to
Javascript.
Not at all, Lasse.

Your * Javascript is only as axiomatically specified, I presume,
while my Javascript allows talking about change and improvement.

* ... idea of ...

I prefer to discuss mine.

-
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 27 '08 #21

This discussion thread is closed

Replies have been disabled for this discussion.