<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-14005</id>
	<title>Nabble - E Lang</title>
	<updated>2009-12-13T18:37:14Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/E-Lang-f14005.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/E-Lang-f14005.html" />
	<subtitle type="html">Discussion of E and other capability languages.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26772278</id>
	<title>Re: [Caja] Functional auditor for Cajita: EQ vs referential transparency</title>
	<published>2009-12-13T18:37:14Z</published>
	<updated>2009-12-13T18:37:14Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt; 1. Prevent pure [Cajita] code from using identity-revealing operations.
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;This includes both primitives like === and !==,
&lt;br&gt;&lt;br&gt;I should also have mentioned == and != here.
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;and APIs such as
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;cajita.identical, Array.prototype.indexOf/lastIndexOf or the
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;proposed EphemeronTable -- these would simply not be whitelisted
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;as deep-frozen.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26772278&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26772278/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26772278.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26772194</id>
	<title>Re: [Caja] Functional auditor for Cajita: EQ vs referential transparency</title>
	<published>2009-12-13T18:24:41Z</published>
	<updated>2009-12-13T18:24:41Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; David Wagner wrote:
&lt;br&gt;&amp;gt;&amp;gt; David-Sarah Hopwood &amp;nbsp;wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; In fact I'm wrong [in claiming that @pure implies referentially transparent
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; in my original proposal], as shown by this example:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;/*@pure*/ function f() { return cajita.deepFreeze({}); }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;const a = f();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;const b = f();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;/*@pure*/ function g(x) { return x === a; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;g(a); // true
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;g(b); // false
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Since a and b are observably different, either f or g must not
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; be referentially transparent.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm not sure if I follow this example. &amp;nbsp;Can you elaborate
&lt;br&gt;&amp;gt;&amp;gt; what it illustrates?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Here's my understanding of the bit I think you may be getting at:
&lt;br&gt;&amp;gt;&amp;gt; conceptually, a referentially transparent function should satisfy the
&lt;br&gt;&amp;gt;&amp;gt; following property: whenever x=y, then f(x)=f(y). &amp;nbsp;However, to fill out this
&lt;br&gt;&amp;gt;&amp;gt; definition, we must define what we mean by &amp;quot;=&amp;quot;: what form of equality we
&lt;br&gt;&amp;gt;&amp;gt; have in mind.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Yes. But whatever we mean by &amp;quot;=&amp;quot;, it's clear that we can't reasonably
&lt;br&gt;&amp;gt; have true = false. In the above example, we can apply referential
&lt;br&gt;&amp;gt; transparency once to conclude a = b (since the calls to f() have no
&lt;br&gt;&amp;gt; arguments -- or they could have been passed the same argument), and
&lt;br&gt;&amp;gt; again to conclude g(a) = g(b). Therefore either true = false, or
&lt;br&gt;&amp;gt; one of f or g is not referentially transparent. But both were declared
&lt;br&gt;&amp;gt; as @pure, therefore @pure does not imply referentially transparent for
&lt;br&gt;&amp;gt; any definition of = satisfying not(true = false).
&lt;/div&gt;&lt;/div&gt;It appears that the Functional auditor in the design described in
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.erights.org/elang/kernel/auditors/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.erights.org/elang/kernel/auditors/&lt;/a&gt;&amp;gt; suffers from essentially
&lt;br&gt;the same issue.
&lt;br&gt;&lt;br&gt;Consider the E equivalent of the above example (note that 'def obj {}' has
&lt;br&gt;no mutable state):
&lt;br&gt;&lt;br&gt;&amp;nbsp; def f() :DeepFrozen { return def obj {} }
&lt;br&gt;&amp;nbsp; f :Functional &amp;nbsp;# passes
&lt;br&gt;&lt;br&gt;&amp;nbsp; def a := f()
&lt;br&gt;&amp;nbsp; def b := f()
&lt;br&gt;&lt;br&gt;&amp;nbsp; def g(x) :boolean { return x == a }
&lt;br&gt;&amp;nbsp; g :Functional &amp;nbsp;# passes
&lt;br&gt;&lt;br&gt;&amp;nbsp; g(a) &amp;nbsp;# true
&lt;br&gt;&amp;nbsp; g(b) &amp;nbsp;# false
&lt;br&gt;&lt;br&gt;This is because each 'obj' returned by f is DeepFrozen but not DeepSelfless
&lt;br&gt;(see Figure 3 of &amp;lt;&lt;a href=&quot;http://www.erights.org/elang/kernel/auditors/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.erights.org/elang/kernel/auditors/&lt;/a&gt;&amp;gt;). If a
&lt;br&gt;Functional object returns an object that is not DeepSelfless, then it fails
&lt;br&gt;to be referentially transparent.
&lt;br&gt;&lt;br&gt;The auditors page doesn't explicitly claim that the Functional guard is
&lt;br&gt;supposed to provide referential transparency. However, it does say that
&lt;br&gt;&lt;br&gt;# if we know that an object is functional, we can cache its output,
&lt;br&gt;# reorder calls, or skip repeated calls ...
&lt;br&gt;&lt;br&gt;Memoization (cacheing) depends on referential transparency.
&lt;br&gt;&lt;br&gt;The problem with memoizing functions that don't return a DeepSelfless
&lt;br&gt;value has been noted before in this thread started by Kevin Reid:
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2006-May/011206.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2006-May/011206.html&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;Kevin first suggested requiring the return of a memoized function to
&lt;br&gt;be guarded by DeepPassByCopy (which implies DeepSelfless). In the
&lt;br&gt;specific case of memoization -- not necessarily for other uses of
&lt;br&gt;referential transparency -- there are workarounds that are less
&lt;br&gt;restrictive than this. For example MarkM gave a solution that involved
&lt;br&gt;only adding a non-DeepPassByCopy result to the memo table when it is
&lt;br&gt;seen twice: &amp;lt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2006-May/011207.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2006-May/011207.html&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;Alternatively, for some applications it may be possible to use a
&lt;br&gt;different form of cache, call it an &amp;quot;interning memoizer&amp;quot;, as described
&lt;br&gt;in &amp;lt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2006-May/011270.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2006-May/011270.html&lt;/a&gt;&amp;gt; and
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2006-May/011282.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2006-May/011282.html&lt;/a&gt;&amp;gt;.
&lt;br&gt;&lt;br&gt;However, those approaches are specific to memoization. If we want
&lt;br&gt;to avoid the problem more generally, then we have roughly three
&lt;br&gt;options:
&lt;br&gt;&lt;br&gt;1. Prevent pure code from using identity-revealing operations. This
&lt;br&gt;&amp;nbsp; &amp;nbsp;includes both primitives like === and !==, and APIs such as
&lt;br&gt;&amp;nbsp; &amp;nbsp;cajita.identical, Array.prototype.indexOf/lastIndexOf or the
&lt;br&gt;&amp;nbsp; &amp;nbsp;proposed EphemeronTable -- these would simply not be whitelisted
&lt;br&gt;&amp;nbsp; &amp;nbsp;as deep-frozen.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;Note that impure code can still observe that a pure function has
&lt;br&gt;&amp;nbsp; &amp;nbsp;returned different objects on different calls. But it is reasonable
&lt;br&gt;&amp;nbsp; &amp;nbsp;to ask impure code not to rely on that -- whereas if pure code itself
&lt;br&gt;&amp;nbsp; &amp;nbsp;could make such an observation, it would defeat the point of auditing
&lt;br&gt;&amp;nbsp; &amp;nbsp;as a method of determining properties of code without having to
&lt;br&gt;&amp;nbsp; &amp;nbsp;review it.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;This introduces the problem that pure code no longer has access
&lt;br&gt;&amp;nbsp; &amp;nbsp;to *any* efficient equality predicate. Below is an equality test that
&lt;br&gt;&amp;nbsp; &amp;nbsp;is safe to give to pure code; in the cases where egal would do
&lt;br&gt;&amp;nbsp; &amp;nbsp;structural comparison, it sticks its head in the sand and returns
&lt;br&gt;&amp;nbsp; &amp;nbsp;undefined. (This at least has the advantage of bounding the time
&lt;br&gt;&amp;nbsp; &amp;nbsp;for comparison to be proportional to the number of own properties
&lt;br&gt;&amp;nbsp; &amp;nbsp;in any tested object. It would be O(1) if not for the calls to
&lt;br&gt;&amp;nbsp; &amp;nbsp;Object.isFrozen, and an ES5 implementation *should* cache whether
&lt;br&gt;&amp;nbsp; &amp;nbsp;objects are frozen.)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/**
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; * If both x and y are frozen objects, return undefined.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; * Otherwise give the same result as cajita.identical(x, y).
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; */
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;function ostrichEq(x, y) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (x === y) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (x === Object(x)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// x and y are the same object. If that object is frozen, return
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// undefined.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return Object.isFrozen(x) ? undefined : true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Usually true, but might be a false positive for 0 and -0.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return x !== 0 || 1/x === 1/y;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (x === Object(x)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (y === Object(y) &amp;&amp; Object.isFrozen(x) &amp;&amp; Object.isFrozen(y)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// x and y are different objects, but both are frozen.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return undefined;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return false;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Usually false, but might be a false negative for NaN and NaN.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return x !== x &amp;&amp; y !== y;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;2. Force all DeepFrozen objects to be DeepSelfless. Note that if
&lt;br&gt;&amp;nbsp; &amp;nbsp;functions can be DeepFrozen, then this is equivalent to using
&lt;br&gt;&amp;nbsp; &amp;nbsp;the same comparison for function instances as the original egal
&lt;br&gt;&amp;nbsp; &amp;nbsp;(see the definition of 'egal-function' on page 8 of Baker's paper
&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;lt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&lt;/a&gt;&amp;gt;),
&lt;br&gt;&amp;nbsp; &amp;nbsp;which compares function identities and lexical environments.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;However, this may weaken encapsulation for DeepFrozen objects that
&lt;br&gt;&amp;nbsp; &amp;nbsp;wouldn't otherwise have been DeepSelfless.
&lt;br&gt;&lt;br&gt;3. [For E] Define a Pure auditor that is like Functional but also
&lt;br&gt;&amp;nbsp; &amp;nbsp;requires all returns to be guarded by DeepSelfless or DeepPassByCopy.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;[For Cajita] Introduce a deep-selfless auditor, and strengthen @pure
&lt;br&gt;&amp;nbsp; &amp;nbsp;so that a rewritten @pure function checks that its return value is
&lt;br&gt;&amp;nbsp; &amp;nbsp;deep-selfless.
&lt;br&gt;&lt;br&gt;&amp;gt; Forbidding use of === and !== in a deep-frozen function solves the
&lt;br&gt;&amp;gt; problem.
&lt;br&gt;&lt;br&gt;This is option 1 above.
&lt;br&gt;&lt;br&gt;&amp;gt; It's similar to Joe-E restricting on == and != to non-value
&lt;br&gt;&amp;gt; types, but we can't do that in Cajita because it is untyped.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26772194&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26772194/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26772194.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26764433</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-13T00:46:40Z</published>
	<updated>2009-12-13T00:46:40Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt; (Nor can we usefully weaken referential transparency to use different
&lt;br&gt;&amp;gt; versions of equality on the left and right of the implication, since
&lt;br&gt;&amp;gt; then it could not be applied compositionally.)
&lt;br&gt;&lt;br&gt;I should have said: we cannot usefully weaken referential transparency
&lt;br&gt;to use a coarser version of equality on the right than on the left.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26764433&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26764433/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26764433.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26764174</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-12T23:34:28Z</published>
	<updated>2009-12-12T23:34:28Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David Wagner wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; David-Sarah Hopwood &amp;nbsp;wrote:
&lt;br&gt;&amp;gt;&amp;gt; In fact I'm wrong here, as shown by this example:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;/*@pure*/ function f() { return cajita.deepFreeze({}); }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;const a = f();
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;const b = f();
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;/*@pure*/ function g(x) { return x === a; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;g(a); // true
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;g(b); // false
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Since a and b are observably different, either f or g must not
&lt;br&gt;&amp;gt;&amp;gt; be referentially transparent.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm not sure if I follow this example. &amp;nbsp;Can you elaborate
&lt;br&gt;&amp;gt; what it illustrates?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Here's my understanding of the bit I think you may be getting at:
&lt;br&gt;&amp;gt; conceptually, a referentially transparent function should satisfy the
&lt;br&gt;&amp;gt; following property: whenever x=y, then f(x)=f(y). &amp;nbsp;However, to fill out this
&lt;br&gt;&amp;gt; definition, we must define what we mean by &amp;quot;=&amp;quot;: what form of equality we
&lt;br&gt;&amp;gt; have in mind.
&lt;/div&gt;&lt;/div&gt;Yes. But whatever we mean by &amp;quot;=&amp;quot;, it's clear that we can't reasonably
&lt;br&gt;have true = false. In the above example, we can apply referential
&lt;br&gt;transparency once to conclude a = b (since the calls to f() have no
&lt;br&gt;arguments -- or they could have been passed the same argument), and
&lt;br&gt;again to conclude g(a) = g(b). Therefore either true = false, or
&lt;br&gt;one of f or g is not referentially transparent. But both were declared
&lt;br&gt;as @pure, therefore @pure does not imply referentially transparent for
&lt;br&gt;any definition of = satisfying not(true = false).
&lt;br&gt;&lt;br&gt;(Nor can we usefully weaken referential transparency to use different
&lt;br&gt;versions of equality on the left and right of the implication, since
&lt;br&gt;then it could not be applied compositionally.)
&lt;br&gt;&lt;br&gt;Forbidding use of === and !== in a deep-frozen function solves the
&lt;br&gt;problem. It's similar to Joe-E restricting on == and != to non-value
&lt;br&gt;types, but we can't do that in Cajita because it is untyped.
&lt;br&gt;&lt;br&gt;If I'm not mistaken, Joe-E *could* also relax its restriction on ==
&lt;br&gt;and !=, and possibly its restrictions on calling nondeterministic APIs,
&lt;br&gt;by only applying them to (I think) methods of Immutable objects.
&lt;br&gt;&lt;br&gt;&amp;gt; I posted earlier about this:
&lt;br&gt;&amp;gt; &amp;nbsp; My post (see the &amp;quot;P.P.S.&amp;quot;)
&lt;br&gt;&amp;gt; &amp;nbsp; &lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2009-December/013327.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2009-December/013327.html&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;nbsp; Ihab's response:
&lt;br&gt;&amp;gt; &amp;nbsp; &lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2009-December/013335.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2009-December/013335.html&lt;/a&gt;&lt;br&gt;&amp;gt; The response was that in this context, equality is given by ===.
&lt;br&gt;&lt;br&gt;Ihab only said that Cajita currently exposes ===. That doesn't imply
&lt;br&gt;that = is ===. In my proposal, = is Henry Baker's 'egal'. (I should
&lt;br&gt;write out a definition of egal in Cajita to make this clearer.)
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; So that means that we only get guarantees about two invocations to
&lt;br&gt;&amp;gt; g if the arguments in both invocations are equal according to &amp;quot;===&amp;quot;;
&lt;br&gt;&amp;gt; otherwise, there are no promises.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You give an example of two invocation to g, namely g(a) and g(b),
&lt;br&gt;&amp;gt; where the arguments in both arguments are not equal according to
&lt;br&gt;&amp;gt; &amp;quot;===&amp;quot;, namely, a !== b. &amp;nbsp;So you shouldn't expect the results of those
&lt;br&gt;&amp;gt; two invocations to be related at all; the two results might be
&lt;br&gt;&amp;gt; entirely unrelated.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Does this make sense? &amp;nbsp;Have I missed something?
&lt;/div&gt;&lt;/div&gt;I think you missed that referential transparency was being applied
&lt;br&gt;twice (probably my fault for not spelling out the argument in more
&lt;br&gt;detail).
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26764174&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26764174/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26764174.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26762612</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-12T16:51:57Z</published>
	<updated>2009-12-12T16:51:57Z</updated>
	<author>
		<name>David Wagner-3</name>
	</author>
	<content type="html">David-Sarah Hopwood &amp;nbsp;wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;In fact I'm wrong here, as shown by this example:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;/*@pure*/ function f() { return cajita.deepFreeze({}); }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;const a = f();
&lt;br&gt;&amp;gt; &amp;nbsp;const b = f();
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;/*@pure*/ function g(x) { return x === a; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;g(a); // true
&lt;br&gt;&amp;gt; &amp;nbsp;g(b); // false
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;Since a and b are observably different, either f or g must not
&lt;br&gt;&amp;gt;be referentially transparent.
&lt;/div&gt;&lt;br&gt;I'm not sure if I follow this example. &amp;nbsp;Can you elaborate
&lt;br&gt;what it illustrates?
&lt;br&gt;&lt;br&gt;Here's my understanding of the bit I think you may be getting at:
&lt;br&gt;conceptually, a referentially transparent function should satisfy the
&lt;br&gt;following property: whenever x=y, then f(x)=f(y). &amp;nbsp;However, to fill out this
&lt;br&gt;definition, we must define what we mean by &amp;quot;=&amp;quot;: what form of equality we
&lt;br&gt;have in mind. &amp;nbsp;The definition of referential transparency is parametrized
&lt;br&gt;by your definition of equality, and to provide a full definition you
&lt;br&gt;must decide what you mean by &amp;quot;=&amp;quot;. &amp;nbsp;See Section 3.2 and follow-on
&lt;br&gt;discussion in the Joe-E purity paper (Finifter et al 2008).
&lt;br&gt;&lt;br&gt;Note that we only get guarantees about the result of the function
&lt;br&gt;in case when the arguments in both arguments are equal according
&lt;br&gt;to &amp;quot;=&amp;quot;. &amp;nbsp;Otherwise, all bets are off.
&lt;br&gt;&lt;br&gt;I posted earlier about this:
&lt;br&gt;&amp;nbsp; My post (see the &amp;quot;P.P.S.&amp;quot;)
&lt;br&gt;&amp;nbsp; &lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2009-December/013327.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2009-December/013327.html&lt;/a&gt;&lt;br&gt;&amp;nbsp; Ihab's response:
&lt;br&gt;&amp;nbsp; &lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2009-December/013335.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2009-December/013335.html&lt;/a&gt;&lt;br&gt;The response was that in this context, equality is given by ===.
&lt;br&gt;So that means that we only get guarantees about two invocations to
&lt;br&gt;g if the arguments in both invocations are equal according to &amp;quot;===&amp;quot;;
&lt;br&gt;otherwise, there are no promises.
&lt;br&gt;&lt;br&gt;You give an example of two invocation to g, namely g(a) and g(b),
&lt;br&gt;where the arguments in both arguments are not equal according to
&lt;br&gt;&amp;quot;===&amp;quot;, namely, a !== b. &amp;nbsp;So you shouldn't expect the results of those
&lt;br&gt;two invocations to be related at all; the two results might be
&lt;br&gt;entirely unrelated.
&lt;br&gt;&lt;br&gt;Does this make sense? &amp;nbsp;Have I missed something?
&lt;br&gt;&lt;br&gt;In Joe-E, pure functions are useful for relating two invocations
&lt;br&gt;when the arguments are value types that can be compared according
&lt;br&gt;to their value (object identity is not visible). &amp;nbsp;When you talk
&lt;br&gt;about invocations where the arguments have visible object identity,
&lt;br&gt;things get much messier. &amp;nbsp;Object identity introduces a can of
&lt;br&gt;worms to discussion of purity.
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26762612&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26762612.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26739280</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-10T22:15:50Z</published>
	<updated>2009-12-10T22:15:50Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; /**
&lt;br&gt;&amp;gt; &amp;nbsp;* Check that a chain of property accesses starting from obj, and
&lt;br&gt;&amp;gt; &amp;nbsp;* using property names given by subsequent arguments, is guaranteed
&lt;br&gt;&amp;gt; &amp;nbsp;* to give a constant result. No getters are invoked during the check.
&lt;br&gt;&amp;gt; &amp;nbsp;*
&lt;br&gt;&amp;gt; &amp;nbsp;* This can be used to relax the condition that all accesses to captured
&lt;br&gt;&amp;gt; &amp;nbsp;* variables of a deepFrozen function are deepFrozen. For instance,
&lt;br&gt;&amp;gt; &amp;nbsp;* if a @deepFrozen function uses foo only by accessing foo.bar.baz,
&lt;br&gt;&amp;gt; &amp;nbsp;* then rather than requiring foo to be deepFrozen, we can require
&lt;br&gt;&amp;gt; &amp;nbsp;* just that foo.bar.baz gives a constant result.
&lt;br&gt;&amp;gt; &amp;nbsp;* I.e. we verify that foo is statically const, and generate a call to
&lt;br&gt;&amp;gt; &amp;nbsp;* checkConstant(foo, 'bar', 'baz') for each scope in which foo
&lt;br&gt;&amp;gt; &amp;nbsp;* might be different.
&lt;br&gt;&amp;gt; &amp;nbsp;*/
&lt;br&gt;&amp;gt; function checkConstant(obj /*, ...*/) {
&lt;/div&gt;&lt;/div&gt;The implementation of checkConstant was consistent with the comment, but
&lt;br&gt;it was not quite what is needed. It's also necessary to check that the
&lt;br&gt;final result of the chain of property accesses is deepFrozen. This must
&lt;br&gt;be done by 'checkConstant' rather than separately by the rewritten code,
&lt;br&gt;because only checkConstant has access to the 'value' fields obtained from
&lt;br&gt;the data property descriptors. (Calling 'checkDeepFrozen(foo.bar.baz)'
&lt;br&gt;would be incorrect since that might invoke getters.)
&lt;br&gt;&lt;br&gt;So, the first sentence of the comment should say &amp;quot;a constant result value
&lt;br&gt;that is deepFrozen.&amp;quot; A small change is also needed to the implementation:
&lt;br&gt;&lt;br&gt;&amp;nbsp; function checkConstantAndDeepFrozen(obj /*, ...*/) {
&lt;br&gt;&amp;gt; &amp;nbsp; var i = 1;
&lt;br&gt;&amp;gt; &amp;nbsp; test: while (true) {
&lt;br&gt;- &amp;nbsp; &amp;nbsp; if (i &amp;gt;= arguments.length) return;
&lt;br&gt;+ &amp;nbsp; &amp;nbsp; if (i &amp;gt;= arguments.length) {
&lt;br&gt;+ &amp;nbsp; &amp;nbsp; &amp;nbsp; checkDeepFrozen(obj);
&lt;br&gt;+ &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&lt;br&gt;+ &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;(The other two early returns are correct since they only occur when the
&lt;br&gt;current value of 'obj' is already known to be deepFrozen.)
&lt;br&gt;&lt;br&gt;Note that the special case checkConstantAndDeepFrozen(obj) is the same as
&lt;br&gt;checkDeepFrozen(obj), so some refactoring might be in order.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26739280&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26739280/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26739280.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26737085</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-10T16:46:35Z</published>
	<updated>2009-12-10T16:46:35Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt;&amp;gt; It would be possible to make the argument and result checks optional
&lt;br&gt;&amp;gt;&amp;gt; depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;&amp;gt;&amp;gt; /*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;&amp;gt;&amp;gt; and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;&amp;gt;&amp;gt; copacetic.)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; In that case, /*@pure*/ would imply unconditional determinism
&lt;br&gt;&amp;gt;&amp;gt; (referential transparency), whereas /*@functional*/ would only imply
&lt;br&gt;&amp;gt;&amp;gt; determinism for calls for which all arguments are copacetic.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In fact I'm wrong here, as shown by this example:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; /*@pure*/ function f() { return cajita.deepFreeze({}); }
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; const a = f();
&lt;br&gt;&amp;gt; &amp;nbsp; const b = f();
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; /*@pure*/ function g(x) { return x === a; }
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; g(a); // true
&lt;br&gt;&amp;gt; &amp;nbsp; g(b); // false
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Since a and b are observably different, either f or g must not
&lt;br&gt;&amp;gt; be referentially transparent.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; A Cajita that only exposed an egal operator, as defined in
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; Henry Baker,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;quot;Equal Rights for Functional Objects, or The More Things Change,
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;The More They Are the Same&amp;quot;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;lt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; would solve this problem. (It might be difficult to tame away all
&lt;br&gt;&amp;gt; indirect access to ===, though.)
&lt;/div&gt;&lt;/div&gt;A more lenient option is to prohibit access to === and !== only to
&lt;br&gt;copacetic functions. So, the above code would be invalid because
&lt;br&gt;g is annotated as @pure, therefore required to be copacetic.
&lt;br&gt;This would transitively deny access to === and !== as long as no
&lt;br&gt;tamed objects are incorrectly marked as being copacetic.
&lt;br&gt;(The fact that some code has access to === and !== precludes the
&lt;br&gt;optimizations I referred to in my previous post, but those optimizations
&lt;br&gt;would not be available in an ECMAScript implementation anyway.)
&lt;br&gt;&lt;br&gt;@pure and @functional functions would still be able to use egal,
&lt;br&gt;if its implementation were &amp;quot;deemed&amp;quot; copacetic (exempted from the
&lt;br&gt;restriction on === and !==).
&lt;br&gt;&lt;br&gt;From now on, I'll rename copacetic to deep-frozen, since it is close
&lt;br&gt;enough to the E concept that I don't think there will be any confusion.
&lt;br&gt;(Bye bye, copacetic. We'll miss you.)
&lt;br&gt;I'll also rename the @functional annotation to @deepFrozen.
&lt;br&gt;&lt;br&gt;I'll write out the differences between the auditing in E, Joe-E, and
&lt;br&gt;my proposal for Cajita in a separate post. In the meantime, here is most
&lt;br&gt;of the run-time support that could be used to implement deep-frozen
&lt;br&gt;auditing in Cajita:
&lt;br&gt;&lt;br&gt;&lt;br&gt;// Using &amp;lt;&lt;a href=&quot;http://wiki.ecmascript.org/doku.php?id=strawman:weak_references&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://wiki.ecmascript.org/doku.php?id=strawman:weak_references&lt;/a&gt;&amp;gt;.
&lt;br&gt;function makeWeakTable() { return new EphemeronTable(true); }
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* An auditDeepFrozen entry has the value:
&lt;br&gt;&amp;nbsp;* &amp;nbsp; false or a sour pumpkin, if the key is known not to be deepFrozen
&lt;br&gt;&amp;nbsp;* &amp;nbsp; true or a tasty pumpkin, if the key is known to be deepFrozen.
&lt;br&gt;&amp;nbsp;*
&lt;br&gt;&amp;nbsp;* The objects traversed in a given checkDeepFrozen run are set
&lt;br&gt;&amp;nbsp;* to a unique pumpkin object, which is used to detect loops.
&lt;br&gt;&amp;nbsp;* A &amp;quot;tasty pumpkin&amp;quot; is an object with a 'tasty' field set to
&lt;br&gt;&amp;nbsp;* true, indicating that its run succeeded. A &amp;quot;sour pumpkin&amp;quot; has
&lt;br&gt;&amp;nbsp;* its 'tasty' field set to false. If a run fails, the entries
&lt;br&gt;&amp;nbsp;* pointing to its pumpkin (which has no 'tasty' field) are left
&lt;br&gt;&amp;nbsp;* in the table but are ignored, i.e. treated as equivalent to a
&lt;br&gt;&amp;nbsp;* missing entry, on subsequent runs.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;/*const*/ var auditDeepFrozen = makeWeakTable();
&lt;br&gt;&lt;br&gt;/*const*/ var tastyPumpkin = Object.freeze({ tasty: true });
&lt;br&gt;/*const*/ var sourPumpkin = Object.freeze({ tasty: false });
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* A functionMarks entry has the value:
&lt;br&gt;&amp;nbsp;* &amp;nbsp; 'deepFrozen', if marked as @deepFrozen
&lt;br&gt;&amp;nbsp;* &amp;nbsp; 'pure', &amp;nbsp; &amp;nbsp; &amp;nbsp; if marked as @pure.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;/*const*/ var functionMarks = makeWeakTable();
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* Check that obj satisfies the conditions to be deepFrozen, and throw
&lt;br&gt;&amp;nbsp;* AuditError if not. Memoize any results for non-primitive objects in
&lt;br&gt;&amp;nbsp;* the auditDeepFrozen table.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;function checkDeepFrozen(obj) {
&lt;br&gt;&amp;nbsp; if (isPrimitive(obj)) return;
&lt;br&gt;&lt;br&gt;&amp;nbsp; /*const*/ var pumpkin = {};
&lt;br&gt;&amp;nbsp; if (isDeepFrozen(obj, pumpkin)) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; // Mark all visited objects that participated in a loop as deepFrozen.
&lt;br&gt;&amp;nbsp; &amp;nbsp; pumpkin.tasty = true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; Object.freeze(pumpkin);
&lt;br&gt;&amp;nbsp; &amp;nbsp; return;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&amp;nbsp; Object.freeze(pumpkin);
&lt;br&gt;&amp;nbsp; throw new AuditError();
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* Return true if obj is definitely deepFrozen, false if it definitely
&lt;br&gt;&amp;nbsp;* isn't, and pumpkin if we encountered a loop.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;function isDeepFrozen(obj, pumpkin) {
&lt;br&gt;&amp;nbsp; var t = auditDeepFrozen.get(obj);
&lt;br&gt;&amp;nbsp; if (t) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; /*const*/ var tasty = t.tasty;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (tasty !== undefined) return tasty;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (t === pumpkin) return t;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; test: {
&lt;br&gt;&amp;nbsp; &amp;nbsp; // Function instances must be marked in order to be deepFrozen.
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (typeof obj === 'function' &amp;&amp; !functionMarks.get(obj))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; break test;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; // Mark that we are checking obj, to avoid infinite loops.
&lt;br&gt;&amp;nbsp; &amp;nbsp; // Progress depends on single-threadedness; multiple threads
&lt;br&gt;&amp;nbsp; &amp;nbsp; // could livelock by treading on each other's pumpkins.
&lt;br&gt;&amp;nbsp; &amp;nbsp; auditDeepFrozen.put(obj, pumpkin);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; t = isDeepFrozen(Object.getPrototypeOf(obj), pumpkin);
&lt;br&gt;&amp;nbsp; &amp;nbsp; var loopy = t === pumpkin;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (!t || !Object.isFrozen(obj)) break test;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /*const*/ var ownprops = Object.getOwnPropertyNames(obj);
&lt;br&gt;&amp;nbsp; &amp;nbsp; for (var i = 0; i &amp;lt; ownprops.length; i++) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*const*/ var prop = ownprops[i];
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /*const*/ var desc = Object.getOwnPropertyDescriptor(obj, prop);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if ('value' in desc) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t = isDeepFrozen(desc.value, pumpkin);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; loopy = loopy || t === pumpkin;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!t) break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; } else {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t = isDeepFrozen(desc.get, pumpkin);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; loopy = loopy || t === pumpkin;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // It would be sufficient to check that the setter is deepFrozen,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // but a setter that doesn't actually set anything is misleading.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!t || desc.set !== null) break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; // If the traversal from this object did not hit a loop, then we can
&lt;br&gt;&amp;nbsp; &amp;nbsp; // memoize it as deepFrozen even if the overall checkDeepFrozen run
&lt;br&gt;&amp;nbsp; &amp;nbsp; // fails.
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (loopy) return pumpkin;
&lt;br&gt;&amp;nbsp; &amp;nbsp; auditDeepFrozen.put(obj, tastyPumpkin);
&lt;br&gt;&amp;nbsp; &amp;nbsp; return true;
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; // break test:
&lt;br&gt;&amp;nbsp; auditDeepFrozen.put(obj, sourPumpkin);
&lt;br&gt;&amp;nbsp; return false;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* Check that a chain of property accesses starting from obj, and
&lt;br&gt;&amp;nbsp;* using property names given by subsequent arguments, is guaranteed
&lt;br&gt;&amp;nbsp;* to give a constant result. No getters are invoked during the check.
&lt;br&gt;&amp;nbsp;*
&lt;br&gt;&amp;nbsp;* This can be used to relax the condition that all accesses to captured
&lt;br&gt;&amp;nbsp;* variables of a deepFrozen function are deepFrozen. For instance,
&lt;br&gt;&amp;nbsp;* if a @deepFrozen function uses foo only by accessing foo.bar.baz,
&lt;br&gt;&amp;nbsp;* then rather than requiring foo to be deepFrozen, we can require
&lt;br&gt;&amp;nbsp;* just that foo.bar.baz gives a constant result.
&lt;br&gt;&amp;nbsp;* I.e. we verify that foo is statically const, and generate a call to
&lt;br&gt;&amp;nbsp;* checkConstant(foo, 'bar', 'baz') for each scope in which foo
&lt;br&gt;&amp;nbsp;* might be different.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;function checkConstant(obj /*, ...*/) {
&lt;br&gt;&amp;nbsp; var i = 1;
&lt;br&gt;&amp;nbsp; test: while (true) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (i &amp;gt;= arguments.length) return;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /*const*/ var t = auditDeepFrozen.get(obj);
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (t &amp;&amp; t.tasty) return; &amp;nbsp;// optimization
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /*const*/ var prop = arguments[i];
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; var desc;
&lt;br&gt;&amp;nbsp; &amp;nbsp; try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; desc = Object.getOwnPropertyDescriptor(obj, prop);
&lt;br&gt;&amp;nbsp; &amp;nbsp; } catch (e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // getOwnPropertyDescriptor *should* only throw if Type(obj) is not
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // Object. However the ES5 spec doesn't explicitly say that
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // [[GetOwnProperty]] for a host object can't throw (even though
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // that would break stuff).
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (isPrimitive(obj)) return;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if (desc === undefined) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // If prop doesn't exist as an own-property, then the object must be
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // non-Extensible, and we continue using the object's prototype.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // If the property doesn't exist in the prototype chain and all
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // objects in the chain are non-Extensible, then obj will eventually
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // be null, which is allowed by the primitive case above.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (Object.isExtensible(obj)) break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; obj = Object.getPrototypeOf(obj);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; continue;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; // The property must be non-Configurable. If it is a data property,
&lt;br&gt;&amp;nbsp; &amp;nbsp; // it must also be non-Writable, and we continue checking that
&lt;br&gt;&amp;nbsp; &amp;nbsp; // subsequent property accesses on the value are constant. If it
&lt;br&gt;&amp;nbsp; &amp;nbsp; // is an accessor property, we conservatively require its getter
&lt;br&gt;&amp;nbsp; &amp;nbsp; // to be deepFrozen (note that the getter may be null).
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; if (desc.configurable !== false) break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; if ('value' in desc) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (desc.writable !== false) break test;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; obj = desc.value;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; i++; &amp;nbsp;// next access
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; continue;
&lt;br&gt;&amp;nbsp; &amp;nbsp; } else {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; checkDeepFrozen(desc.get);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // Since the getter is deepFrozen, there is no need to check
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // subsequent properties in the chain (which is lucky, because
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // we can't).
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; // break test:
&lt;br&gt;&amp;nbsp; auditDeepFrozen.put(obj, sourPumpkin);
&lt;br&gt;&amp;nbsp; throw new AuditError();
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;function isPrimitive(obj) {
&lt;br&gt;&amp;nbsp; if (obj == null) return true; &amp;nbsp;// null and undefined
&lt;br&gt;&amp;nbsp; /*const*/ var t = typeof obj;
&lt;br&gt;&amp;nbsp; return t === 'number' || t === 'string' || t === 'boolean';
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;/**
&lt;br&gt;&amp;nbsp;* This would be called by the rewritten code that instantiates an
&lt;br&gt;&amp;nbsp;* annotated function.
&lt;br&gt;&amp;nbsp;*/
&lt;br&gt;function markFunc(mark, obj) {
&lt;br&gt;&amp;nbsp; if (typeof obj !== 'function' || functionMarks.get(obj) !== undefined)
&lt;br&gt;&amp;nbsp; &amp;nbsp; throw new TypeError();
&lt;br&gt;&lt;br&gt;&amp;nbsp; Object.freeze(obj);
&lt;br&gt;&amp;nbsp; functionMarks.put(obj, mark);
&lt;br&gt;&amp;nbsp; checkDeepFrozen(obj);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26737085&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26737085/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26737085.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26705468</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T21:40:47Z</published>
	<updated>2009-12-08T21:40:47Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">Mike Samuel wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 2009/12/8 David-Sarah Hopwood &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26705468&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;var f = /*@functional*/ function (evil, s) {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;evil(s);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;};
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; f is now copacetic.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; If passed the arguments (freeze(eval), 'a = 0') it will modify the
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; lexical environment, and I think both arguments are copacetic
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; according to the frozen functions definition,
&lt;br&gt;&amp;gt;&amp;gt; In
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;f(cajita.freeze(eval), 'a = 0;');
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; there is a free variable reference 'eval', and the global eval is
&lt;br&gt;&amp;gt;&amp;gt; not accessible to Cajita code. So this program is not valid Cajita.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; So it is not a goal for a copacetic program to maintain its properties
&lt;br&gt;&amp;gt; when functions defined in it are called by non-strict non-cajita code.
&lt;br&gt;&amp;gt; So it is the copacetic program parsers responsibility to make sure
&lt;br&gt;&amp;gt; that such functions do not escape to where they could be called that
&lt;br&gt;&amp;gt; way?
&lt;/div&gt;&lt;/div&gt;Non-Cajita ECMAScript code would not be able to mutate copacetic values,
&lt;br&gt;because copacetic would imply deep-frozen using ES5 Object.freeze.
&lt;br&gt;Also, non-global eval can only mutate variables in the lexical scope
&lt;br&gt;in which 'eval' is referenced. So non-Cajita code could only manipulate
&lt;br&gt;its own scope this way, not Cajita scopes.
&lt;br&gt;&lt;br&gt;This assumes that non-Cajita code can't diddle with the copacetic
&lt;br&gt;marker tags, or otherwise interfere with the security of the Cajita
&lt;br&gt;runtime. Note that any implementation of a marker tag using a property
&lt;br&gt;on the marked object would not work here, because non-Cajita code would
&lt;br&gt;be able to set that property on a new object in the same way (and with
&lt;br&gt;the same attributes) as the Cajita runtime.
&lt;br&gt;&lt;br&gt;However, a Name or Trademark mechanism (which can be implemented in
&lt;br&gt;terms of weak hashtables), could work.
&lt;br&gt;See &amp;lt;&lt;a href=&quot;http://wiki.ecmascript.org/doku.php?id=strawman:weak_references&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://wiki.ecmascript.org/doku.php?id=strawman:weak_references&lt;/a&gt;&amp;gt;,
&lt;br&gt;subsection 'Trademarking', for instance.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26705468&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26705468/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26705468.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26705061</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T20:29:44Z</published>
	<updated>2009-12-08T20:29:44Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">Bill Frantz wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26705061&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt; (David-Sarah Hopwood) on Tuesday, December 8, 2009 wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] 
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; ...
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; [*] Please, don't let this provisional term catch on :-) In practice
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;we can probably get away with using &amp;quot;pure&amp;quot;, or think of something
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;better.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Here you have coined a technical meaning for a term that is, as far as I
&lt;br&gt;&amp;gt; know, new to computer science, and you want to change it? &amp;nbsp;:-)
&lt;/div&gt;&lt;/div&gt;Oh dear, I fear I may have opened a Pandora's box ...
&lt;br&gt;&lt;br&gt;# 1919 &amp;nbsp;I. BACHELLER &amp;nbsp;/Man for Ages/ iv. 69 'As to looks I'd call him, as ye
&lt;br&gt;# might say, real copasetic.' Mrs. Lukins expressed this opinion solemnly...
&lt;br&gt;# Its last word stood for nothing more than an indefinite depth of meaning.
&lt;br&gt;-- OED
&lt;br&gt;&lt;br&gt;&amp;lt;&lt;a href=&quot;http://en.wiktionary.org/wiki/Talk:copacetic&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://en.wiktionary.org/wiki/Talk:copacetic&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.worldwidewords.org/weirdwords/ww-cop1.htm&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.worldwidewords.org/weirdwords/ww-cop1.htm&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26705061&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26705061/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26705061.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26704992</id>
	<title>Causeway support for AmbientTalk</title>
	<published>2009-12-08T20:17:04Z</published>
	<updated>2009-12-08T20:17:04Z</updated>
	<author>
		<name>Tom Van Cutsem-2</name>
	</author>
	<content type="html">Hi all,&lt;br&gt;&lt;br&gt;I just wanted to share with the E community that AmbientTalk (also a communicating event loop language, directly influenced by E) now also supports Terry Stanley&amp;#39;s Causeway debugger. I wrote up a small tutorial on how to use Causeway in AmbientTalk, which I think might be useful for those with a general interest in Causeway:&lt;br&gt;
&lt;a href=&quot;http://code.google.com/p/ambienttalk/wiki/Debugging&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/ambienttalk/wiki/Debugging&lt;/a&gt;&lt;br&gt;&lt;br&gt;Thanks go to Terry, Mark and Tyler for their support and, of course, for providing Causeway in the first place.&lt;br&gt;
&lt;br&gt;Cheers,&lt;br&gt;Tom&lt;br&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26704992&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Causeway-support-for-AmbientTalk-tp26704992p26704992.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26704116</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T18:13:01Z</published>
	<updated>2009-12-08T18:13:01Z</updated>
	<author>
		<name>Mike Samuel</name>
	</author>
	<content type="html">2009/12/8 David-Sarah Hopwood &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26704116&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Mike Samuel wrote:
&lt;br&gt;&amp;gt;&amp;gt; Is the following copacetic by that definition?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   (function (eval, s) {
&lt;br&gt;&amp;gt;&amp;gt;     eval(s);
&lt;br&gt;&amp;gt;&amp;gt;   })
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Trivially no, since it isn't annotated as functional nor pure.
&lt;br&gt;&amp;gt; Also, Cajita is a subset of ES5-strict, which prohibits 'eval' from
&lt;br&gt;&amp;gt; being used as a formal parameter name:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; # It is a SyntaxError if the identifier eval or arguments appears
&lt;br&gt;&amp;gt; # within a FormalParameterList of a strict mode FunctionDeclaration
&lt;br&gt;&amp;gt; # or FunctionExpression (13.1)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Let's fix these problems first:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  var f = /*@functional*/ function (evil, s) {
&lt;br&gt;&amp;gt;    evil(s);
&lt;br&gt;&amp;gt;  };
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; f is now copacetic.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; If passed the arguments (freeze(eval), 'a = 0') it will modify the
&lt;br&gt;&amp;gt;&amp;gt; lexical environment, and I think both arguments are copacetic
&lt;br&gt;&amp;gt;&amp;gt; according to the frozen functions definition,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  f(cajita.freeze(eval), 'a = 0;');
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; there is a free variable reference 'eval', and the global eval is
&lt;br&gt;&amp;gt; not accessible to Cajita code. So this program is not valid Cajita.
&lt;/div&gt;&lt;br&gt;So it is not a goal for a copacetic program to maintain its properties
&lt;br&gt;when functions defined in it are called by non-strict non-cajita code.
&lt;br&gt;So it is the copacetic program parsers responsibility to make sure
&lt;br&gt;that such functions do not escape to where they could be called that
&lt;br&gt;way?
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Suppose that a hypothetical Cajita were extended with a restricted
&lt;br&gt;&amp;gt; cajita.eval function. (It would be frozen so we don't need to explicitly
&lt;br&gt;&amp;gt; freeze it.) Then cajita.eval could not be marked as copacetic. Still,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  f(cajita.eval, 'a = 0;');
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; would succeed up to the point where it calls cajita.eval('a = 0;')
&lt;br&gt;&amp;gt; (because f is only marked as functional, not pure, so its
&lt;br&gt;&amp;gt; cajita.eval argument is not required to be copacetic). But then it
&lt;br&gt;&amp;gt; would fail because 'a = 0;' is not a valid Cajita program (it tries to
&lt;br&gt;&amp;gt; assign to a free variable).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Even if it did not fail for that reason, cajita.eval would presumably
&lt;br&gt;&amp;gt; be modelled on ES5-strict &amp;quot;global eval&amp;quot;, which cannot directly modify
&lt;br&gt;&amp;gt; its lexical environment.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; OTOH,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  f(cajita.eval, 'var a = 0;');
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; would succeed, but is harmless.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Note that single-argument cajita.eval would have to treat its code as
&lt;br&gt;&amp;gt; being in an empty lexical environment (apart from safe globals).
&lt;br&gt;&amp;gt; There could potentially be a variant that would support evaluation
&lt;br&gt;&amp;gt; in an explicitly specified environment:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  var f2 = /*@functional*/ function (evil, s, e) {
&lt;br&gt;&amp;gt;    evil(s, e);
&lt;br&gt;&amp;gt;  };
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  var env = {a: undefined};
&lt;br&gt;&amp;gt;  f(cajita.eval, 'a = 0;', env);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; but since env is not frozen (and neither cajita.eval nor f are pure),
&lt;br&gt;&amp;gt; there is no reason to expect this code to be prevented from mutating
&lt;br&gt;&amp;gt; env.a.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; David-Sarah Hopwood  ⚥  &lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26704116&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26704116.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26703749</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T17:23:45Z</published>
	<updated>2009-12-08T17:23:45Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">Mike Samuel wrote:
&lt;br&gt;&amp;gt; Is the following copacetic by that definition?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; (function (eval, s) {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; eval(s);
&lt;br&gt;&amp;gt; &amp;nbsp; })
&lt;br&gt;&lt;br&gt;Trivially no, since it isn't annotated as functional nor pure.
&lt;br&gt;Also, Cajita is a subset of ES5-strict, which prohibits 'eval' from
&lt;br&gt;being used as a formal parameter name:
&lt;br&gt;&lt;br&gt;# It is a SyntaxError if the identifier eval or arguments appears
&lt;br&gt;# within a FormalParameterList of a strict mode FunctionDeclaration
&lt;br&gt;# or FunctionExpression (13.1)
&lt;br&gt;&lt;br&gt;Let's fix these problems first:
&lt;br&gt;&lt;br&gt;&amp;nbsp; var f = /*@functional*/ function (evil, s) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; evil(s);
&lt;br&gt;&amp;nbsp; };
&lt;br&gt;&lt;br&gt;f is now copacetic.
&lt;br&gt;&lt;br&gt;&amp;gt; If passed the arguments (freeze(eval), 'a = 0') it will modify the
&lt;br&gt;&amp;gt; lexical environment, and I think both arguments are copacetic
&lt;br&gt;&amp;gt; according to the frozen functions definition,
&lt;br&gt;&lt;br&gt;In
&lt;br&gt;&lt;br&gt;&amp;nbsp; f(cajita.freeze(eval), 'a = 0;');
&lt;br&gt;&lt;br&gt;there is a free variable reference 'eval', and the global eval is
&lt;br&gt;not accessible to Cajita code. So this program is not valid Cajita.
&lt;br&gt;&lt;br&gt;Suppose that a hypothetical Cajita were extended with a restricted
&lt;br&gt;cajita.eval function. (It would be frozen so we don't need to explicitly
&lt;br&gt;freeze it.) Then cajita.eval could not be marked as copacetic. Still,
&lt;br&gt;&lt;br&gt;&amp;nbsp; f(cajita.eval, 'a = 0;');
&lt;br&gt;&lt;br&gt;would succeed up to the point where it calls cajita.eval('a = 0;')
&lt;br&gt;(because f is only marked as functional, not pure, so its
&lt;br&gt;cajita.eval argument is not required to be copacetic). But then it
&lt;br&gt;would fail because 'a = 0;' is not a valid Cajita program (it tries to
&lt;br&gt;assign to a free variable).
&lt;br&gt;&lt;br&gt;Even if it did not fail for that reason, cajita.eval would presumably
&lt;br&gt;be modelled on ES5-strict &amp;quot;global eval&amp;quot;, which cannot directly modify
&lt;br&gt;its lexical environment.
&lt;br&gt;&lt;br&gt;OTOH,
&lt;br&gt;&lt;br&gt;&amp;nbsp; f(cajita.eval, 'var a = 0;');
&lt;br&gt;&lt;br&gt;would succeed, but is harmless.
&lt;br&gt;&lt;br&gt;Note that single-argument cajita.eval would have to treat its code as
&lt;br&gt;being in an empty lexical environment (apart from safe globals).
&lt;br&gt;There could potentially be a variant that would support evaluation
&lt;br&gt;in an explicitly specified environment:
&lt;br&gt;&lt;br&gt;&amp;nbsp; var f2 = /*@functional*/ function (evil, s, e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; evil(s, e);
&lt;br&gt;&amp;nbsp; };
&lt;br&gt;&lt;br&gt;&amp;nbsp; var env = {a: undefined};
&lt;br&gt;&amp;nbsp; f(cajita.eval, 'a = 0;', env);
&lt;br&gt;&lt;br&gt;but since env is not frozen (and neither cajita.eval nor f are pure),
&lt;br&gt;there is no reason to expect this code to be prevented from mutating
&lt;br&gt;env.a.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26703749&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26703749/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26703749.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26703365</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T16:31:39Z</published>
	<updated>2009-12-08T16:31:39Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt; It would be possible to make the argument and result checks optional
&lt;br&gt;&amp;gt; depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;&amp;gt; /*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;&amp;gt; and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;&amp;gt; copacetic.)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; In that case, /*@pure*/ would imply unconditional determinism
&lt;br&gt;&amp;gt; (referential transparency), whereas /*@functional*/ would only imply
&lt;br&gt;&amp;gt; determinism for calls for which all arguments are copacetic.
&lt;br&gt;&lt;br&gt;In fact I'm wrong here, as shown by this example:
&lt;br&gt;&lt;br&gt;&amp;nbsp; /*@pure*/ function f() { return cajita.deepFreeze({}); }
&lt;br&gt;&lt;br&gt;&amp;nbsp; const a = f();
&lt;br&gt;&amp;nbsp; const b = f();
&lt;br&gt;&lt;br&gt;&amp;nbsp; /*@pure*/ function g(x) { return x === a; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; g(a); // true
&lt;br&gt;&amp;nbsp; g(b); // false
&lt;br&gt;&lt;br&gt;Since a and b are observably different, either f or g must not
&lt;br&gt;be referentially transparent.
&lt;br&gt;&lt;br&gt;A Cajita that only exposed an egal operator, as defined in
&lt;br&gt;&lt;br&gt;&amp;nbsp; Henry Baker,
&lt;br&gt;&amp;nbsp; &amp;quot;Equal Rights for Functional Objects, or The More Things Change,
&lt;br&gt;&amp;nbsp; &amp;nbsp;The More They Are the Same&amp;quot;
&lt;br&gt;&amp;nbsp; &amp;lt;&lt;a href=&quot;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.9999&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;would solve this problem. (It might be difficult to tame away all
&lt;br&gt;indirect access to ===, though.)
&lt;br&gt;&lt;br&gt;Unfortunately egal isn't constant-time. Ideally, an implementation
&lt;br&gt;would optimize it by unifying pointers when they are found to be egal;
&lt;br&gt;in that case it still wouldn't be constant-time, but repeated tests
&lt;br&gt;of egality would be efficient, and redundant subgraphs could be
&lt;br&gt;garbage-collected. This would be similar to hash-consing but possibly
&lt;br&gt;less expensive (depending on whether pointers can be efficiently
&lt;br&gt;unified). Unification can also potentially be done on garbage collection,
&lt;br&gt;as suggested in Baker's paper.
&lt;br&gt;&lt;br&gt;&lt;br&gt;[I was disturbed to see that the first Google hit for &amp;quot;egal operator&amp;quot;
&lt;br&gt;is a travel agent, not even with the same spelling. What is the world
&lt;br&gt;coming to -- do people have no appreciation for computer science?]
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26703365&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26703365/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26703365.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26701973</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T14:26:27Z</published>
	<updated>2009-12-08T14:26:27Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 2:06 PM, Mike Samuel &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701973&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mikesamuel@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Is the following copacetic by that definition?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  (function (eval, s) {
&lt;br&gt;&amp;gt;    eval(s);
&lt;br&gt;&amp;gt;  })
&lt;br&gt;&lt;br&gt;It is &amp;quot;E-copacetic&amp;quot; where the E stands for &amp;quot;evil&amp;quot;.
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701973&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26701973.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26701943</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T14:23:42Z</published>
	<updated>2009-12-08T14:23:42Z</updated>
	<author>
		<name>Mark S. Miller-2</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 2:06 PM, Mike Samuel &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701943&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mikesamuel@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Is the following copacetic by that definition?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  (function (eval, s) {
&lt;br&gt;&amp;gt;    eval(s);
&lt;br&gt;&amp;gt;  })
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; If passed the arguments (freeze(eval), 'a = 0') it will modify the
&lt;br&gt;&amp;gt; lexical environment, and I think both arguments are copacetic
&lt;br&gt;&amp;gt; according to the frozen functions definition,
&lt;br&gt;&lt;br&gt;Aren't we presuming Cajita, in which case this is illegal? If instead
&lt;br&gt;full ES5-strict, then the above &amp;quot;eval(s)&amp;quot; code should be considered a
&lt;br&gt;special form causing all variables in its lexical scope to be
&lt;br&gt;considered accessible and (if assignable) potentially assigned.
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 2009/12/8  &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701943&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt;&amp;gt;:
&lt;br&gt;&amp;gt;&amp;gt; On Tue, Dec 8, 2009 at 12:05 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701943&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Note that this implies that the lexical environment of each successfully
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; created instance is observationally immutable, not just that it can't
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; be directly changed by that instance. I.e. it also can't be changed
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; indirectly via an operation on an argument ...
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; D'oww, I missed that one! Yes, thank you.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; The implementation sketch I gave would preclude that use case because
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; if the supplied argument values are not copacetic, the object's read()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; method would throw. This might have been too conservative -- if those
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; argument checks were omitted then the property above (that the function
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; instance can't change its lexical environment) would still hold.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Yes.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; It would be possible to make the argument and result checks optional
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; /*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; copacetic.)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Yeah I think we're talking about two, possibly both useful classes of
&lt;br&gt;&amp;gt;&amp;gt; behavior here.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; What a fun discussion! Thanks for starting it.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Glad to oblige. :)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Ihab
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&amp;nbsp; &amp;nbsp; Cheers,
&lt;br&gt;&amp;nbsp; &amp;nbsp; --MarkM
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701943&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26701943.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26701713</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T14:06:53Z</published>
	<updated>2009-12-08T14:06:53Z</updated>
	<author>
		<name>Mike Samuel</name>
	</author>
	<content type="html">Is the following copacetic by that definition?
&lt;br&gt;&lt;br&gt;&amp;nbsp; (function (eval, s) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; eval(s);
&lt;br&gt;&amp;nbsp; })
&lt;br&gt;&lt;br&gt;If passed the arguments (freeze(eval), 'a = 0') it will modify the
&lt;br&gt;lexical environment, and I think both arguments are copacetic
&lt;br&gt;according to the frozen functions definition,
&lt;br&gt;&lt;br&gt;&lt;br&gt;2009/12/8 &amp;nbsp;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701713&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Tue, Dec 8, 2009 at 12:05 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701713&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; Note that this implies that the lexical environment of each successfully
&lt;br&gt;&amp;gt;&amp;gt; created instance is observationally immutable, not just that it can't
&lt;br&gt;&amp;gt;&amp;gt; be directly changed by that instance. I.e. it also can't be changed
&lt;br&gt;&amp;gt;&amp;gt; indirectly via an operation on an argument ...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; D'oww, I missed that one! Yes, thank you.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The implementation sketch I gave would preclude that use case because
&lt;br&gt;&amp;gt;&amp;gt; if the supplied argument values are not copacetic, the object's read()
&lt;br&gt;&amp;gt;&amp;gt; method would throw. This might have been too conservative -- if those
&lt;br&gt;&amp;gt;&amp;gt; argument checks were omitted then the property above (that the function
&lt;br&gt;&amp;gt;&amp;gt; instance can't change its lexical environment) would still hold.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; It would be possible to make the argument and result checks optional
&lt;br&gt;&amp;gt;&amp;gt; depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;&amp;gt;&amp;gt; /*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;&amp;gt;&amp;gt; and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;&amp;gt;&amp;gt; copacetic.)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Yeah I think we're talking about two, possibly both useful classes of
&lt;br&gt;&amp;gt; behavior here.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; What a fun discussion! Thanks for starting it.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Glad to oblige. :)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Ihab
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;&amp;gt;
&lt;/div&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701713&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26701713.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26701229</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T13:33:47Z</published>
	<updated>2009-12-08T13:33:47Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 12:05 PM, David-Sarah Hopwood
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701229&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Note that this implies that the lexical environment of each successfully
&lt;br&gt;&amp;gt; created instance is observationally immutable, not just that it can't
&lt;br&gt;&amp;gt; be directly changed by that instance. I.e. it also can't be changed
&lt;br&gt;&amp;gt; indirectly via an operation on an argument ...
&lt;br&gt;&lt;br&gt;D'oww, I missed that one! Yes, thank you.
&lt;br&gt;&lt;br&gt;&amp;gt; The implementation sketch I gave would preclude that use case because
&lt;br&gt;&amp;gt; if the supplied argument values are not copacetic, the object's read()
&lt;br&gt;&amp;gt; method would throw. This might have been too conservative -- if those
&lt;br&gt;&amp;gt; argument checks were omitted then the property above (that the function
&lt;br&gt;&amp;gt; instance can't change its lexical environment) would still hold.
&lt;br&gt;&lt;br&gt;Yes.
&lt;br&gt;&lt;br&gt;&amp;gt; It would be possible to make the argument and result checks optional
&lt;br&gt;&amp;gt; depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;&amp;gt; /*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;&amp;gt; and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;&amp;gt; copacetic.)
&lt;br&gt;&lt;br&gt;Yeah I think we're talking about two, possibly both useful classes of
&lt;br&gt;behavior here.
&lt;br&gt;&lt;br&gt;&amp;gt; What a fun discussion! Thanks for starting it.
&lt;br&gt;&lt;br&gt;Glad to oblige. :)
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26701229&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26701229.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26700418</id>
	<title>Re: [Caja] Functional auditor for Cajita [correction]</title>
	<published>2009-12-08T12:42:29Z</published>
	<updated>2009-12-08T12:42:29Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Mark S. Miller wrote:
&lt;br&gt;&amp;gt;&amp;gt; On Tue, Dec 8, 2009 at 8:47 AM, &amp;nbsp;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700418&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Thank you for the writeup; interesting. Just one point of motivation
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; that perhaps I missed from the original post:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700418&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I'm getting at something similar but distinct, call it &amp;quot;i-copacetic&amp;quot;.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; :) &amp;nbsp;Specifically:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects on its lexical environment regardless
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; of its argument values
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; The motivation is this: An object's state is managed by some
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; surrounding system. However, it is allowed to expose &amp;quot;read()&amp;quot; services
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; to the outside world that do not participate in this state management.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Each &amp;quot;read()&amp;quot; service may side-effect the supplied arguments, but it
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; must not side-effect the lexical environment of the service (i.e., the
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; object itself).
&lt;br&gt;&amp;gt;&amp;gt; How is this different from E's DeepFrozen or Joe-E's Immutable?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Since E has no nondeterministic ambient operations, DeepFrozen in E
&lt;br&gt;&amp;gt; implies determinism for calls with only DeepFrozen arguments. But in
&lt;br&gt;&amp;gt; general, if a language does have nondeterministic primitives (say,
&lt;br&gt;&amp;gt; nondeterministic floating point arithmetic), then a copacetic function
&lt;br&gt;&amp;gt; would be verified to be implemented in a deterministic sublanguage.
&lt;br&gt;&amp;gt; In that case, DeepFrozen would differ from (copacetic without the
&lt;br&gt;&amp;gt; argument and result checks).
&lt;/div&gt;&lt;/div&gt;Actually, DeepFrozen necessarily implies non-access to nondeterminism,
&lt;br&gt;since otherwise a &amp;quot;DeepFrozen&amp;quot; value could be observed to change.
&lt;br&gt;So DeepFrozen is the same as (copacetic without the argument and
&lt;br&gt;result checks) -- or at least to what I intended that to mean, despite
&lt;br&gt;some imprecision in the definition.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700418&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26700418/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26700418.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26700175</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T12:25:14Z</published>
	<updated>2009-12-08T12:25:14Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">Mark S. Miller wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On Tue, Dec 8, 2009 at 8:47 AM, &amp;nbsp;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700175&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; Thank you for the writeup; interesting. Just one point of motivation
&lt;br&gt;&amp;gt;&amp;gt; that perhaps I missed from the original post:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700175&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&amp;gt;&amp;gt; I'm getting at something similar but distinct, call it &amp;quot;i-copacetic&amp;quot;.
&lt;br&gt;&amp;gt;&amp;gt; :) &amp;nbsp;Specifically:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects on its lexical environment regardless
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; of its argument values
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; The motivation is this: An object's state is managed by some
&lt;br&gt;&amp;gt;&amp;gt; surrounding system. However, it is allowed to expose &amp;quot;read()&amp;quot; services
&lt;br&gt;&amp;gt;&amp;gt; to the outside world that do not participate in this state management.
&lt;br&gt;&amp;gt;&amp;gt; Each &amp;quot;read()&amp;quot; service may side-effect the supplied arguments, but it
&lt;br&gt;&amp;gt;&amp;gt; must not side-effect the lexical environment of the service (i.e., the
&lt;br&gt;&amp;gt;&amp;gt; object itself).
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; How is this different from E's DeepFrozen or Joe-E's Immutable?
&lt;/div&gt;&lt;/div&gt;Since E has no nondeterministic ambient operations, DeepFrozen in E
&lt;br&gt;implies determinism for calls with only DeepFrozen arguments. But in
&lt;br&gt;general, if a language does have nondeterministic primitives (say,
&lt;br&gt;nondeterministic floating point arithmetic), then a copacetic function
&lt;br&gt;would be verified to be implemented in a deterministic sublanguage.
&lt;br&gt;In that case, DeepFrozen would differ from (copacetic without the
&lt;br&gt;argument and result checks). But otherwise it is very similar.
&lt;br&gt;&lt;br&gt;I haven't had chance to reread the Joe-E functional purity paper yet
&lt;br&gt;(&lt;a href=&quot;http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf&lt;/a&gt;), so I'll
&lt;br&gt;refrain from commenting on Immutable for the time being.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26700175&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26700175/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26700175.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26699891</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T12:05:20Z</published>
	<updated>2009-12-08T12:05:20Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26699891&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Thank you for the writeup; interesting. Just one point of motivation
&lt;br&gt;&amp;gt; that perhaps I missed from the original post:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26699891&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm getting at something similar but distinct, call it &amp;quot;i-copacetic&amp;quot;.
&lt;br&gt;&amp;gt; :) &amp;nbsp;Specifically:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; - it has no side effects on its lexical environment regardless
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;of its argument values
&lt;/div&gt;&lt;/div&gt;You're right, that's a better definition.
&lt;br&gt;&lt;br&gt;The implementation sketch I gave for 'copacetic' actually ensures that
&lt;br&gt;property already, even though the definition above doesn't. That's
&lt;br&gt;because the verification that captured variables are const is done
&lt;br&gt;statically, and the check that captured values are copacetic is done
&lt;br&gt;for each instantiation of a function marked as /*@functional*/, before
&lt;br&gt;any call to that instance.
&lt;br&gt;&lt;br&gt;Note that this implies that the lexical environment of each successfully
&lt;br&gt;created instance is observationally immutable, not just that it can't
&lt;br&gt;be directly changed by that instance. I.e. it also can't be changed
&lt;br&gt;indirectly via an operation on an argument (even if the checks for
&lt;br&gt;arguments being copacetic are dropped as discussed below), or by other
&lt;br&gt;code.
&lt;br&gt;&lt;br&gt;&amp;gt; The motivation is this: An object's state is managed by some
&lt;br&gt;&amp;gt; surrounding system. However, it is allowed to expose &amp;quot;read()&amp;quot; services
&lt;br&gt;&amp;gt; to the outside world that do not participate in this state management.
&lt;br&gt;&amp;gt; Each &amp;quot;read()&amp;quot; service may side-effect the supplied arguments, but it
&lt;br&gt;&amp;gt; must not side-effect the lexical environment of the service (i.e., the
&lt;br&gt;&amp;gt; object itself).
&lt;br&gt;&lt;br&gt;The implementation sketch I gave would preclude that use case because
&lt;br&gt;if the supplied argument values are not copacetic, the object's read()
&lt;br&gt;method would throw. This might have been too conservative -- if those
&lt;br&gt;argument checks were omitted then the property above (that the function
&lt;br&gt;instance can't change its lexical environment) would still hold.
&lt;br&gt;&lt;br&gt;Similar cases occur for higher order functions. For example 'map' or
&lt;br&gt;'fold' functions have no side effects except via their arguments.
&lt;br&gt;With the checks that arguments and result are copacetic, you would need
&lt;br&gt;both /*@functional*/ and non-/*@functional*/ variants of each such
&lt;br&gt;function, with the same implementation. If the argument *and* result
&lt;br&gt;checks were omitted (as David Wagner suggested), the same function
&lt;br&gt;could serve both cases.
&lt;br&gt;&lt;br&gt;Another motivation, of course, is that not doing these checks is more
&lt;br&gt;efficient.
&lt;br&gt;&lt;br&gt;It would be possible to make the argument and result checks optional
&lt;br&gt;depending on the function annotation: say, /*@pure*/ includes them but
&lt;br&gt;/*@functional*/ doesn't. (The environment checks would be the same,
&lt;br&gt;and both /*@pure*/ and /*@functional*/ would mark instances as
&lt;br&gt;copacetic.)
&lt;br&gt;&lt;br&gt;In that case, /*@pure*/ would imply unconditional determinism
&lt;br&gt;(referential transparency), whereas /*@functional*/ would only imply
&lt;br&gt;determinism for calls for which all arguments are copacetic.
&lt;br&gt;&lt;br&gt;What a fun discussion! Thanks for starting it.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26699891&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26699891/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26699891.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26699218</id>
	<title>Re: [Caja] Functional auditor for Cajita [minor correction]</title>
	<published>2009-12-08T11:17:57Z</published>
	<updated>2009-12-08T11:17:57Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt; Consider the following example (in ECMAScript syntax since I'll just get
&lt;br&gt;&amp;gt; confused switching between ECMAScript and E):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; var f = /*@functional*/ function() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; return cajita.deepFreeze(function() { return {}; });
&lt;br&gt;&amp;gt; &amp;nbsp; };
&lt;br&gt;&amp;gt; &amp;nbsp; var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;
&lt;br&gt;&lt;br&gt;This should have been obj = f()().
&lt;br&gt;&lt;br&gt;(Static typing would have caught that bug :-)
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; If this followed equivalent auditor definitions to E, it would pass the
&lt;br&gt;&amp;gt; audit checks, even though 'var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;' causes
&lt;br&gt;&amp;gt; an *internal* side-effect (that is, a side effect to an object that does
&lt;br&gt;&amp;gt; not escape).
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Note that if we wrap this with another function g:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; var g = /*@functional*/ function() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; var f = /*@functional*/ function() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; return cajita.deepFreeze(function() { return {}; });
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;
&lt;/div&gt;&lt;/div&gt;Same here.
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; return cajita.deepFreeze(obj);
&lt;br&gt;&amp;gt; &amp;nbsp; }
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; the object returned by g (with p:&amp;quot;surprise&amp;quot;) is deep-frozen by the
&lt;br&gt;&amp;gt; time it is returned, so f and g arguably *are* functional, even
&lt;br&gt;&amp;gt; though the object f returns is *not* functional.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26699218&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26699218/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26699218.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26698068</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T10:04:34Z</published>
	<updated>2009-12-08T10:04:34Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 1:08 AM, David-Sarah Hopwood
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26698068&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; David Wagner wrote:
&lt;br&gt;&amp;gt;&amp;gt; If I understand correctly, this seems overly strict.  It should
&lt;br&gt;&amp;gt;&amp;gt; be safe for a functionally pure function to capture and invoke a
&lt;br&gt;&amp;gt;&amp;gt; reference to a non-copacetic function, shouldn't it?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Yes, provided the return value is deep-frozen. In that case, we
&lt;br&gt;&amp;gt; have almost exactly E's Functional auditor (modulo the lack of
&lt;br&gt;&amp;gt; explicit guards).
&lt;br&gt;&lt;br&gt;Or provided the outer function deep-freezes the return value.
&lt;br&gt;&lt;br&gt;&amp;nbsp; function outer(x) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; return ___.deepFreeze(nonDeepFreezingFunction(x));
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;gt; No, that was an impressively quick and accurate response (but you
&lt;br&gt;&amp;gt; didn't catch the return value error ;-)
&lt;br&gt;&lt;br&gt;I don't think there *is* one. It might be hard to check all that, but still.
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26698068&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26698068.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26697971</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T09:58:41Z</published>
	<updated>2009-12-08T09:58:41Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 1:06 AM, David Wagner &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697971&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;daw@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; David-Sarah Hopwood  wrote:
&lt;br&gt;&amp;gt; P.S. Does Cajita's taming make it a design goal to tame away all access
&lt;br&gt;&amp;gt; to non-determinism?  If not, that's something else you'll have to tackle.
&lt;br&gt;&lt;br&gt;We haven't done that yet but are thinking about it at the moment.
&lt;br&gt;&lt;br&gt;&amp;gt; P.P.S. Does Cajita expose object identity?
&lt;br&gt;&lt;br&gt;At the moment, yes, via JS's &amp;quot;===&amp;quot;.
&lt;br&gt;&lt;br&gt;&amp;gt; If I know that f is purely functional and I call f(o1) and f(o2),
&lt;br&gt;&amp;gt; do you want to be able to infer that f(o1) is &amp;quot;equivalent&amp;quot; to
&lt;br&gt;&amp;gt; f(o2), or are you OK with the possibility that f(o1) might be
&lt;br&gt;&amp;gt; totally unrelated to f(o2)?
&lt;br&gt;&lt;br&gt;Under the circumstances, we would have to be ok with the &amp;quot;unrelated&amp;quot; case.
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697971&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26697971.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26697764</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T09:45:15Z</published>
	<updated>2009-12-08T09:45:15Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 12:26 AM, David Wagner &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697764&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;daw@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Does Cajita have the equivalent of Java's OutOfMemoryError,
&lt;br&gt;&amp;gt; which can be thrown under effectively non-deterministic conditions?
&lt;br&gt;&amp;gt; (The condition under which it is thrown is a deeply non-local
&lt;br&gt;&amp;gt; condition.)
&lt;br&gt;&lt;br&gt;I'm sure there is some interpreter-dependent equivalent. The
&lt;br&gt;&amp;quot;interpreter dependent&amp;quot; part is what makes it thorny though.
&lt;br&gt;&lt;br&gt;&amp;gt; Are we guaranteed in Cajita that whether an exception is thrown at
&lt;br&gt;&amp;gt; any point is a deterministic function of the local state of named
&lt;br&gt;&amp;gt; values involved in a specified computation (not the global state
&lt;br&gt;&amp;gt; of the interpreter; not as a function of values not named explicitly
&lt;br&gt;&amp;gt; in the code)?
&lt;br&gt;&lt;br&gt;I personally don't know; that said, I suspect that, in our world, we
&lt;br&gt;would have to go through each possible state of madness that each JS
&lt;br&gt;embedding in each Web browser could wedge itself into. Nontrivial. :/
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697764&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26697764.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26697506</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T09:28:07Z</published>
	<updated>2009-12-08T09:28:07Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 9:22 AM, Mark S. Miller &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697506&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;erights@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; How is this different from E's DeepFrozen or Joe-E's Immutable?
&lt;br&gt;&lt;br&gt;Ah I see, it's not. :) In fact:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2005-January/010411.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2005-January/010411.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;and especially Kevin Reid's definition in:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/pipermail/e-lang/2005-January/010414.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/pipermail/e-lang/2005-January/010414.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;So functional purity was _not_ what I was after, after all -- _pace_
&lt;br&gt;the very interesting remarks on this thread (thank you posters).
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697506&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26697506.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26697422</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T09:22:09Z</published>
	<updated>2009-12-08T09:22:09Z</updated>
	<author>
		<name>Mark S. Miller-2</name>
	</author>
	<content type="html">On Tue, Dec 8, 2009 at 8:47 AM, &amp;nbsp;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697422&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Thank you for the writeup; interesting. Just one point of motivation
&lt;br&gt;&amp;gt; that perhaps I missed from the original post:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697422&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt;  - that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt;  - it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt;   only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt;  - it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm getting at something similar but distinct, call it &amp;quot;i-copacetic&amp;quot;.
&lt;br&gt;&amp;gt; :)  Specifically:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  - it has no side effects on its lexical environment regardless
&lt;br&gt;&amp;gt;     of its argument values
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The motivation is this: An object's state is managed by some
&lt;br&gt;&amp;gt; surrounding system. However, it is allowed to expose &amp;quot;read()&amp;quot; services
&lt;br&gt;&amp;gt; to the outside world that do not participate in this state management.
&lt;br&gt;&amp;gt; Each &amp;quot;read()&amp;quot; service may side-effect the supplied arguments, but it
&lt;br&gt;&amp;gt; must not side-effect the lexical environment of the service (i.e., the
&lt;br&gt;&amp;gt; object itself).
&lt;/div&gt;&lt;br&gt;How is this different from E's DeepFrozen or Joe-E's Immutable?
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Ihab
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&amp;nbsp; &amp;nbsp; Cheers,
&lt;br&gt;&amp;nbsp; &amp;nbsp; --MarkM
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26697422&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26697422.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26696945</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T08:49:07Z</published>
	<updated>2009-12-08T08:49:07Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696945&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; An auditor could however check that a frozen data structure contains
&lt;br&gt;&amp;gt; only copacetic values, and if so mark it as copacetic. That would give
&lt;br&gt;&amp;gt; a consistent soft effect / auditing system with the desired property.
&lt;br&gt;&lt;br&gt;Yes, cool.
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696945&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26696945.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26696894</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T08:47:42Z</published>
	<updated>2009-12-08T08:47:42Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">Thank you for the writeup; interesting. Just one point of motivation
&lt;br&gt;that perhaps I missed from the original post:
&lt;br&gt;&lt;br&gt;On Mon, Dec 7, 2009 at 11:17 PM, David-Sarah Hopwood
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696894&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;david-sarah@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;  - that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;  - it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;   only called with copacetic argument values, and
&lt;br&gt;&amp;gt;  - it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&lt;br&gt;I'm getting at something similar but distinct, call it &amp;quot;i-copacetic&amp;quot;.
&lt;br&gt;:) &amp;nbsp;Specifically:
&lt;br&gt;&lt;br&gt;&amp;nbsp; - it has no side effects on its lexical environment regardless
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;of its argument values
&lt;br&gt;&lt;br&gt;The motivation is this: An object's state is managed by some
&lt;br&gt;surrounding system. However, it is allowed to expose &amp;quot;read()&amp;quot; services
&lt;br&gt;to the outside world that do not participate in this state management.
&lt;br&gt;Each &amp;quot;read()&amp;quot; service may side-effect the supplied arguments, but it
&lt;br&gt;must not side-effect the lexical environment of the service (i.e., the
&lt;br&gt;object itself).
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696894&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26696894.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26696649</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T08:30:52Z</published>
	<updated>2009-12-08T08:30:52Z</updated>
	<author>
		<name>ihab.awad</name>
	</author>
	<content type="html">On Mon, Dec 7, 2009 at 10:56 PM, Mike Samuel &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696649&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mikesamuel@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; Some values that are not representable in JSON but that are
&lt;br&gt;&amp;gt; probably functional: NaN, +/-Infinity, undefined, Dates.
&lt;br&gt;&lt;br&gt;Good point. These too then. :)
&lt;br&gt;&lt;br&gt;&amp;gt; So functional code can't call functions, but can pass function
&lt;br&gt;&amp;gt; objects around?
&lt;br&gt;&lt;br&gt;That's not what I meant - see below.
&lt;br&gt;&lt;br&gt;&amp;gt; What is the definition of functional?  That evaluating it has no
&lt;br&gt;&amp;gt; side effect?
&lt;br&gt;&lt;br&gt;No side effect except on the arguments supplied.
&lt;br&gt;&lt;br&gt;&amp;gt; Functions capture the lexical environment in which they're defined and
&lt;br&gt;&amp;gt; capture &amp;quot;this&amp;quot;, so it's not pure, as the &amp;quot;purely&amp;quot; in &amp;quot;purely
&lt;br&gt;&amp;gt; functional&amp;quot; above might suggest.
&lt;br&gt;&lt;br&gt;Right, so that's where the compiler would step in and conservatively
&lt;br&gt;annotate certain functions as having no side effects on their lexical
&lt;br&gt;environment.
&lt;br&gt;&lt;br&gt;But it seems this sparked a lot of discussions so off I go to read.... :)
&lt;br&gt;&lt;br&gt;Ihab
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Ihab A.B. Awad, Palo Alto, CA
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26696649&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26696649.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26690789</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T01:08:08Z</published>
	<updated>2009-12-08T01:08:08Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David Wagner wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt;&amp;gt; First let's decide what property we want from a purely functional auditing
&lt;br&gt;&amp;gt;&amp;gt; system. I think the property we want is:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If all values directly referred to by an expression in language L
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;(that is, all captured values and literals, including function literals)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;pass some auditor, then I know that evaluating the expression in L will
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;have no side effects, and the resulting value or exception will be a
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;deterministic function of those values.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hmm. &amp;nbsp;I wonder if this is overly strict. &amp;nbsp;Maybe what we care about
&lt;br&gt;&amp;gt; is observational side-effect-freedom: i.e., it's OK if the function
&lt;br&gt;&amp;gt; internally performs some side-effect on an object it allocated itself
&lt;br&gt;&amp;gt; as long as that side effect is not externally visible. &amp;nbsp;Does that
&lt;br&gt;&amp;gt; sound right?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; e.g., this is all fine, even though it internally performs
&lt;br&gt;&amp;gt; some side-effecting operations:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; /* functional */ function f() {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var n = 0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n++; &amp;nbsp;// OK
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var o = {};
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; o.x = 5; // OK
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return o; // OK
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;/div&gt;&lt;/div&gt;Yes, I think you're right. For an imperative or only-mostly-functional
&lt;br&gt;language, there would be a severe loss of expressiveness in not allowing
&lt;br&gt;internal side effects. (I hadn't intended them to be included as
&lt;br&gt;&amp;quot;side effects&amp;quot; in the above definition, but didn't make that sufficiently
&lt;br&gt;clear.)
&lt;br&gt;&lt;br&gt;&amp;gt; Does Cajita have the equivalent of Java's OutOfMemoryError,
&lt;br&gt;&amp;gt; which can be thrown under effectively non-deterministic conditions?
&lt;br&gt;&amp;gt; (The condition under which it is thrown is a deeply non-local
&lt;br&gt;&amp;gt; condition.)
&lt;br&gt;&lt;br&gt;The current failure of the Caja implementation to prevent Cajita
&lt;br&gt;code from catching such exceptions is issue 460, and other causes of
&lt;br&gt;nondeterminism are issue 1175:
&lt;br&gt;&lt;br&gt;&amp;lt;&lt;a href=&quot;http://code.google.com/p/google-caja/issues/detail?id=460&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/google-caja/issues/detail?id=460&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://code.google.com/p/google-caja/issues/detail?id=1175&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/google-caja/issues/detail?id=1175&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;Idealized Cajita, with these bugs fixed (and no other correctness
&lt;br&gt;bugs in the implementation or underlying platform), would be fail-stop
&lt;br&gt;deterministic -- i.e. the computation can stop at an arbitrary point
&lt;br&gt;in case of failure, but is deterministic up to that point.
&lt;br&gt;&lt;br&gt;&amp;gt; Are we guaranteed in Cajita that whether an exception is thrown at
&lt;br&gt;&amp;gt; any point is a deterministic function of the local state of named
&lt;br&gt;&amp;gt; values involved in a specified computation (not the global state
&lt;br&gt;&amp;gt; of the interpreter; not as a function of values not named explicitly
&lt;br&gt;&amp;gt; in the code)?
&lt;br&gt;&lt;br&gt;For idealized Cajita, yes.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt; - that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt; - it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt; - it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; If I understand correctly, this seems overly strict. &amp;nbsp;It should
&lt;br&gt;&amp;gt; be safe for a functionally pure function to capture and invoke a
&lt;br&gt;&amp;gt; reference to a non-copacetic function, shouldn't it?
&lt;/div&gt;&lt;/div&gt;Yes, provided the return value is deep-frozen. In that case, we
&lt;br&gt;have almost exactly E's Functional auditor (modulo the lack of
&lt;br&gt;explicit guards).
&lt;br&gt;&lt;br&gt;&amp;gt; I may not be thinking about this clearly, so there may well be
&lt;br&gt;&amp;gt; numerous errors in what I wrote above!
&lt;br&gt;&lt;br&gt;No, that was an impressively quick and accurate response (but you
&lt;br&gt;didn't catch the return value error ;-)
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690789&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26690789/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26690789.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26690765</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T01:06:44Z</published>
	<updated>2009-12-08T01:06:44Z</updated>
	<author>
		<name>David Wagner-3</name>
	</author>
	<content type="html">David-Sarah Hopwood &amp;nbsp;wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;The definitions of the relevant E auditors on that page are:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;Functional:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;Check that the object passes the DeepFrozen auditor and that the
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;return value for each method is guarded by DeepFrozen.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;DeepFrozen:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;Check that all names accessed in the object expression are method
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;arguments or declared final with def, and guarded by the DeepFrozen
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;guard or by the guard for a primitive immutable type (such as int or
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;char).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;The first difference is the check that the return value for each
&lt;br&gt;&amp;gt;method of a Functional object is guarded by DeepFrozen. This should
&lt;br&gt;&amp;gt;correspond to a check that the return value of a copacetic function is
&lt;br&gt;&amp;gt;copacetic, which I forgot. Otherwise, a function like this:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;function() { return {}; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;would be audited as copacetic and run without throwing an exception,
&lt;br&gt;&amp;gt;which is wrong because each instance of {} is mutable.
&lt;/div&gt;&lt;br&gt;In Joe-E, we do consider this function a pure function, and we do allow
&lt;br&gt;pure functions to return mutable objects. &amp;nbsp;So maybe it's worth thinking
&lt;br&gt;about whether there is a compelling reason to forbid mutable return
&lt;br&gt;values from pure functions.
&lt;br&gt;&lt;br&gt;I imagine I've plugged our paper on functionality purity in Joe-E before,
&lt;br&gt;but just in case I haven't mentioned it recently:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.cs.berkeley.edu/~daw/papers/pure-ccs08.pdf&lt;/a&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;P.S. Does Cajita's taming make it a design goal to tame away all access
&lt;br&gt;to non-determinism? &amp;nbsp;If not, that's something else you'll have to tackle.
&lt;br&gt;&lt;br&gt;P.P.S. Does Cajita expose object identity? &amp;nbsp;If it does, what notion of
&lt;br&gt;determinism do you want to use? &amp;nbsp;Suppose o1,o2 are two objects such that
&lt;br&gt;o1 !== o2, but o1 and o2 are &amp;quot;equivalent&amp;quot; in some sense (say, o1[s] ===
&lt;br&gt;o2[s] for all s). &amp;nbsp;If I know that f is purely functional and I call f(o1)
&lt;br&gt;and f(o2), do you want to be able to infer that f(o1) is &amp;quot;equivalent&amp;quot;
&lt;br&gt;to f(o2), or are you OK with the possibility that f(o1) might be totally
&lt;br&gt;unrelated to f(o2)?
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690765&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26690765.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26690467</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T00:40:31Z</published>
	<updated>2009-12-08T00:40:31Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt;&amp;gt; [Cross-posted to e-lang from google-caja-discuss. I suggest continuing on
&lt;br&gt;&amp;gt;&amp;gt; e-lang, since there's not much that is Caja-specific here.]
&lt;br&gt;&amp;gt; [...]
&lt;br&gt;&amp;gt;&amp;gt; It's unclear whether we should call a function &amp;quot;purely functional&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; if it is possible for it to be called with impure arguments (or use
&lt;br&gt;&amp;gt;&amp;gt; captured values that are impure). If it can, and we require it to
&lt;br&gt;&amp;gt;&amp;gt; have no side effects and be deterministic in that case, then almost
&lt;br&gt;&amp;gt;&amp;gt; no useful functions are pure.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;only called with copacetic argument values, and
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;/div&gt;&lt;/div&gt;I meant external side effects here.
&lt;br&gt;&lt;br&gt;&amp;gt; I should also have specified that
&lt;br&gt;&amp;gt; &amp;nbsp;- primitive immutable values are copacetic,
&lt;br&gt;&amp;gt; &amp;nbsp;- frozen objects that directly refer only to copacetic values
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;are copacetic,
&lt;br&gt;&amp;gt; &amp;nbsp;- no values are copacetic unless they can be inferred to be so by
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;the rules above.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I think this corresponds to the Functional auditor in E (see
&lt;br&gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://www.erights.org/elang/kernel/auditors/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.erights.org/elang/kernel/auditors/&lt;/a&gt;&amp;gt;). Is that correct?
&lt;br&gt;&lt;br&gt;To answer my own question, no -- mainly because there is an error in
&lt;br&gt;my proposal.
&lt;br&gt;&lt;br&gt;The definitions of the relevant E auditors on that page are:
&lt;br&gt;&lt;br&gt;&amp;nbsp; Functional:
&lt;br&gt;&amp;nbsp; &amp;nbsp; Check that the object passes the DeepFrozen auditor and that the
&lt;br&gt;&amp;nbsp; &amp;nbsp; return value for each method is guarded by DeepFrozen.
&lt;br&gt;&lt;br&gt;&amp;nbsp; DeepFrozen:
&lt;br&gt;&amp;nbsp; &amp;nbsp; Check that all names accessed in the object expression are method
&lt;br&gt;&amp;nbsp; &amp;nbsp; arguments or declared final with def, and guarded by the DeepFrozen
&lt;br&gt;&amp;nbsp; &amp;nbsp; guard or by the guard for a primitive immutable type (such as int or
&lt;br&gt;&amp;nbsp; &amp;nbsp; char).
&lt;br&gt;&lt;br&gt;The first difference is the check that the return value for each
&lt;br&gt;method of a Functional object is guarded by DeepFrozen. This should
&lt;br&gt;correspond to a check that the return value of a copacetic function is
&lt;br&gt;copacetic, which I forgot. Otherwise, a function like this:
&lt;br&gt;&lt;br&gt;&amp;nbsp; function() { return {}; }
&lt;br&gt;&lt;br&gt;would be audited as copacetic and run without throwing an exception,
&lt;br&gt;which is wrong because each instance of {} is mutable.
&lt;br&gt;&lt;br&gt;So the (unoptimized) rewrite for
&lt;br&gt;&lt;br&gt;&amp;nbsp; const z = ...;
&lt;br&gt;&amp;nbsp; var f = /*@functional*/ function(x, y) { return x+y+z; };
&lt;br&gt;&lt;br&gt;should have been:
&lt;br&gt;&lt;br&gt;&amp;nbsp; const z = ...;
&lt;br&gt;&amp;nbsp; var f = (___.checkCopacetic(z), ___.copaceticFunc(function(x, y) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; ___.checkCopacetic(x); ___.checkCopacetic(y);
&lt;br&gt;&amp;nbsp; &amp;nbsp; return ___.checkCopacetic(x+y+z);
&lt;br&gt;&amp;nbsp; }));
&lt;br&gt;&lt;br&gt;Notice the additional check on x+y+z.
&lt;br&gt;&lt;br&gt;(As it happens, the ECMAScript addition operator always returns either a
&lt;br&gt;string or a number, which are primitive immutable values, therefore the
&lt;br&gt;check can be optimized out in this case.)
&lt;br&gt;&lt;br&gt;&lt;br&gt;The other difference between Functional and my proposal is that
&lt;br&gt;copacetic is defined just in terms of itself; there are not two auditors
&lt;br&gt;with one defined in terms of the other. In this respect, copacetic is
&lt;br&gt;more conservative, and possibly less surprising -- but Functional is
&lt;br&gt;not incorrect in being more lenient.
&lt;br&gt;&lt;br&gt;Consider the following example (in ECMAScript syntax since I'll just get
&lt;br&gt;confused switching between ECMAScript and E):
&lt;br&gt;&lt;br&gt;&amp;nbsp; var f = /*@functional*/ function() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; return cajita.deepFreeze(function() { return {}; });
&lt;br&gt;&amp;nbsp; };
&lt;br&gt;&amp;nbsp; var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;
&lt;br&gt;&lt;br&gt;If this followed equivalent auditor definitions to E, it would pass the
&lt;br&gt;audit checks, even though 'var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;' causes
&lt;br&gt;an *internal* side-effect (that is, a side effect to an object that does
&lt;br&gt;not escape).
&lt;br&gt;&lt;br&gt;Note that if we wrap this with another function g:
&lt;br&gt;&lt;br&gt;&amp;nbsp; var g = /*@functional*/ function() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; var f = /*@functional*/ function() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; return cajita.deepFreeze(function() { return {}; });
&lt;br&gt;&amp;nbsp; &amp;nbsp; };
&lt;br&gt;&amp;nbsp; &amp;nbsp; var obj = f(); obj.p = &amp;quot;surprise&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; return cajita.deepFreeze(obj);
&lt;br&gt;&amp;nbsp; }
&lt;br&gt;&lt;br&gt;the object returned by g (with p:&amp;quot;surprise&amp;quot;) is deep-frozen by the
&lt;br&gt;time it is returned, so f and g arguably *are* functional, even
&lt;br&gt;though the object f returns is *not* functional.
&lt;br&gt;&lt;br&gt;&lt;br&gt;The auditors page also defines
&lt;br&gt;&lt;br&gt;&amp;nbsp; Deterministic:
&lt;br&gt;&amp;nbsp; &amp;nbsp; Check that each name accessed in the object expression is either:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; declared final with def and guarded by the DeepFrozen auditor; or
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; visible only to this object expression and declared guarded by
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Deterministic.
&lt;br&gt;&lt;br&gt;but this is not included in Figure 3 showing the implications between
&lt;br&gt;audited properties. I'm not yet clear on how Functional relates to
&lt;br&gt;Deterministic.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690467&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26690467/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26690467.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26690324</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-08T00:26:44Z</published>
	<updated>2009-12-08T00:26:44Z</updated>
	<author>
		<name>David Wagner-3</name>
	</author>
	<content type="html">David-Sarah Hopwood &amp;nbsp;wrote:
&lt;br&gt;&amp;gt;First let's decide what property we want from a purely functional auditing
&lt;br&gt;&amp;gt;system. I think the property we want is:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;nbsp;If all values directly referred to by an expression in language L
&lt;br&gt;&amp;gt; &amp;nbsp;(that is, all captured values and literals, including function literals)
&lt;br&gt;&amp;gt; &amp;nbsp;pass some auditor, then I know that evaluating the expression in L will
&lt;br&gt;&amp;gt; &amp;nbsp;have no side effects, and the resulting value or exception will be a
&lt;br&gt;&amp;gt; &amp;nbsp;deterministic function of those values.
&lt;br&gt;&lt;br&gt;Hmm. &amp;nbsp;I wonder if this is overly strict. &amp;nbsp;Maybe what we care about
&lt;br&gt;is observational side-effect-freedom: i.e., it's OK if the function
&lt;br&gt;internally performs some side-effect on an object it allocated itself
&lt;br&gt;as long as that side effect is not externally visible. &amp;nbsp;Does that
&lt;br&gt;sound right?
&lt;br&gt;&lt;br&gt;e.g., this is all fine, even though it internally performs
&lt;br&gt;some side-effecting operations:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /* functional */ function f() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var n = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n++; &amp;nbsp;// OK
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var o = {};
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; o.x = 5; // OK
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return o; // OK
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;Does Cajita have the equivalent of Java's OutOfMemoryError,
&lt;br&gt;which can be thrown under effectively non-deterministic conditions?
&lt;br&gt;(The condition under which it is thrown is a deeply non-local
&lt;br&gt;condition.)
&lt;br&gt;&lt;br&gt;Are we guaranteed in Cajita that whether an exception is thrown at
&lt;br&gt;any point is a deterministic function of the local state of named
&lt;br&gt;values involved in a specified computation (not the global state
&lt;br&gt;of the interpreter; not as a function of values not named explicitly
&lt;br&gt;in the code)?
&lt;br&gt;&lt;br&gt;&amp;gt;To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt;&amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt; - that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt; - it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt; &amp;nbsp; only called with copacetic argument values, and
&lt;br&gt;&amp;gt; - it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&lt;br&gt;If I understand correctly, this seems overly strict. &amp;nbsp;It should
&lt;br&gt;be safe for a functionally pure function to capture and invoke a
&lt;br&gt;reference to a non-copacetic function, shouldn't it?
&lt;br&gt;&lt;br&gt;e.g., this should be fine, even though it captures a reference to
&lt;br&gt;the non-functional function sort():
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; /* functional */ function g() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var l = [1, 5, 3];
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sort(l); // OK, even though sort() side-effects its argument
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return l;
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;Is it enough to know that all captured values and all arguments
&lt;br&gt;are transitively immutable, and that the function body uses no
&lt;br&gt;side-effecting or deterministic language primitives (whatever they
&lt;br&gt;may be)?
&lt;br&gt;&lt;br&gt;I may not be thinking about this clearly, so there may well be
&lt;br&gt;numerous errors in what I wrote above!
&lt;br&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26690324&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26690324.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26689804</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-07T23:33:18Z</published>
	<updated>2009-12-07T23:33:18Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">David-Sarah Hopwood wrote:
&lt;br&gt;&amp;gt; [Cross-posted to e-lang from google-caja-discuss. I suggest continuing on
&lt;br&gt;&amp;gt; e-lang, since there's not much that is Caja-specific here.]
&lt;br&gt;[...]
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; It's unclear whether we should call a function &amp;quot;purely functional&amp;quot;
&lt;br&gt;&amp;gt; if it is possible for it to be called with impure arguments (or use
&lt;br&gt;&amp;gt; captured values that are impure). If it can, and we require it to
&lt;br&gt;&amp;gt; have no side effects and be deterministic in that case, then almost
&lt;br&gt;&amp;gt; no useful functions are pure.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;gt; &amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;gt; &amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;gt; &amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;only called with copacetic argument values, and
&lt;br&gt;&amp;gt; &amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;/div&gt;&lt;/div&gt;I should also have specified that
&lt;br&gt;&amp;nbsp;- primitive immutable values are copacetic,
&lt;br&gt;&amp;nbsp;- frozen objects that directly refer only to copacetic values
&lt;br&gt;&amp;nbsp; &amp;nbsp;are copacetic,
&lt;br&gt;&amp;nbsp;- no values are copacetic unless they can be inferred to be so by
&lt;br&gt;&amp;nbsp; &amp;nbsp;the rules above.
&lt;br&gt;&lt;br&gt;I think this corresponds to the Functional auditor in E (see
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://www.erights.org/elang/kernel/auditors/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.erights.org/elang/kernel/auditors/&lt;/a&gt;&amp;gt;). Is that correct?
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26689804&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26689804/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26689804.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26689664</id>
	<title>Re: [Caja] Functional auditor for Cajita</title>
	<published>2009-12-07T23:17:53Z</published>
	<updated>2009-12-07T23:17:53Z</updated>
	<author>
		<name>David-Sarah Hopwood-2</name>
	</author>
	<content type="html">[Cross-posted to e-lang from google-caja-discuss. I suggest continuing on
&lt;br&gt;e-lang, since there's not much that is Caja-specific here.]
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26689664&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ihab.awad@...&lt;/a&gt; wrote:
&lt;br&gt;&amp;gt; Hi folks,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Here is a proposal for a Cajita auditor for purely functional values:
&lt;br&gt;&lt;br&gt;First let's decide what property we want from a purely functional auditing
&lt;br&gt;system. I think the property we want is:
&lt;br&gt;&lt;br&gt;&amp;nbsp; If all values directly referred to by an expression in language L
&lt;br&gt;&amp;nbsp; (that is, all captured values and literals, including function literals)
&lt;br&gt;&amp;nbsp; pass some auditor, then I know that evaluating the expression in L will
&lt;br&gt;&amp;nbsp; have no side effects, and the resulting value or exception will be a
&lt;br&gt;&amp;nbsp; deterministic function of those values.
&lt;br&gt;&lt;br&gt;(In the Caja context, L here would be Cajita, i.e. the expression is
&lt;br&gt;rewritten.)
&lt;br&gt;&lt;br&gt;&amp;gt; 1. All transitively frozen JSON values are functional.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 2. All function values are born frozen, so they are functional *as values*.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 3. The compiler can conservatively annotate certain functions as
&lt;br&gt;&amp;gt; purely functional. This will miss some cases, but again, this is
&lt;br&gt;&amp;gt; conservative.
&lt;br&gt;&lt;br&gt;It's unclear whether we should call a function &amp;quot;purely functional&amp;quot;
&lt;br&gt;if it is possible for it to be called with impure arguments (or use
&lt;br&gt;captured values that are impure). If it can, and we require it to
&lt;br&gt;have no side effects and be deterministic in that case, then almost
&lt;br&gt;no useful functions are pure.
&lt;br&gt;&lt;br&gt;To dodge this issue, let's provisionally call a function *instance*
&lt;br&gt;&amp;quot;copacetic&amp;quot; [*] if:
&lt;br&gt;&amp;nbsp;- that instance has only captured copacetic values, and
&lt;br&gt;&amp;nbsp;- it has no side effects and is deterministic whenever it is
&lt;br&gt;&amp;nbsp; &amp;nbsp;only called with copacetic argument values, and
&lt;br&gt;&amp;nbsp;- it uses no side-effecting or nondeterministic primitives.
&lt;br&gt;&lt;br&gt;(This is a soft effect system, with non-copaceticity being the only effect.
&lt;br&gt;Come to think of it, E-style auditing in general is a soft effect system.)
&lt;br&gt;&lt;br&gt;So, a rewritten copacetic function instance must check that all its
&lt;br&gt;arguments are copacetic before using them. If such a function instance
&lt;br&gt;refers to a captured variable, then we must also check whether the
&lt;br&gt;variable's value is copacetic, and that the variable is 'const' (so
&lt;br&gt;that the value cannot change), before using it. The latter checks can
&lt;br&gt;(and for efficiency, should) be done when instantiating the function,
&lt;br&gt;not on every call.
&lt;br&gt;&lt;br&gt;A failure of these checks would deterministically throw an exception,
&lt;br&gt;which is not counted as a side effect.
&lt;br&gt;&lt;br&gt;&amp;gt; Perhaps we can add some annotation for programmers to
&lt;br&gt;&amp;gt; ask the compiler to treat failure to verify as an error, like:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; var f = /*@functional*/ function(x, y) { ... };
&lt;br&gt;&lt;br&gt;In my proposal this would mark the function instance as copacetic,
&lt;br&gt;add the above argument checks to the function body, and check any
&lt;br&gt;captured values. So for example:
&lt;br&gt;&lt;br&gt;&amp;nbsp; const z = ...;
&lt;br&gt;&amp;nbsp; var f = /*@functional*/ function(x, y) { return x+y+z; };
&lt;br&gt;&lt;br&gt;would be rewritten (ignoring other aspects of the Cajita rewriting) to:
&lt;br&gt;&lt;br&gt;&amp;nbsp; const z = ...;
&lt;br&gt;&amp;nbsp; var f = (___.checkCopacetic(z), ___.copaceticFunc(function(x, y) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; ___.checkCopacetic(x); ___.checkCopacetic(y);
&lt;br&gt;&amp;nbsp; &amp;nbsp; return x+y+z;
&lt;br&gt;&amp;nbsp; }));
&lt;br&gt;&lt;br&gt;&amp;gt; 4. At runtime, any frozen data structure containing only functional
&lt;br&gt;&amp;gt; values as described above can pass a functional auditor, and the
&lt;br&gt;&amp;gt; decision can be memoized on the value.
&lt;br&gt;&lt;br&gt;It's not clear to me that &amp;quot;a frozen data structure containing only
&lt;br&gt;functional values can pass a functional auditor&amp;quot; is correct or sufficient.
&lt;br&gt;Such a structure can contain arbitrary functions, which can refer
&lt;br&gt;to mutable, side-effecting, or nondeterministic values according to
&lt;br&gt;your suggested rules. So, it would not be the case that an arbitrary
&lt;br&gt;expression referring to such a structure would have no side effects
&lt;br&gt;and be deterministic.
&lt;br&gt;&lt;br&gt;An auditor could however check that a frozen data structure contains
&lt;br&gt;only copacetic values, and if so mark it as copacetic. That would give
&lt;br&gt;a consistent soft effect / auditing system with the desired property.
&lt;br&gt;&lt;br&gt;&amp;gt; Does this work?
&lt;br&gt;&lt;br&gt;I think the modification I proposed works. As explained above, it
&lt;br&gt;would require changes to the Cajita rewriting. It also requires 'const'
&lt;br&gt;variables, and a programming style that uses them whereever possible.
&lt;br&gt;&lt;br&gt;&lt;br&gt;[*] Please, don't let this provisional term catch on :-) In practice
&lt;br&gt;&amp;nbsp; &amp;nbsp; we can probably get away with using &amp;quot;pure&amp;quot;, or think of something
&lt;br&gt;&amp;nbsp; &amp;nbsp; better.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;David-Sarah Hopwood &amp;nbsp;⚥ &amp;nbsp;&lt;a href=&quot;http://davidsarah.livejournal.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://davidsarah.livejournal.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;e-lang mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26689664&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;e-lang@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://www.eros-os.org/mailman/listinfo/e-lang&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eros-os.org/mailman/listinfo/e-lang&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;signature.asc&lt;/strong&gt; (300 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26689664/0/signature.asc&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Functional-auditor-for-Cajita-tp26688014p26689664.html" />
</entry>

</feed>
