Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-arrow functions vs Jessie #18

Closed
warner opened this issue Nov 14, 2018 · 6 comments
Closed

non-arrow functions vs Jessie #18

warner opened this issue Nov 14, 2018 · 6 comments

Comments

@warner
Copy link

warner commented Nov 14, 2018

@erights wanted me to file a placeholder ticket, to remind us to think about how Jessie and SES will interact with non-arrow-functions. I think we're still undecided about whether Jessie should provide only arrow functions, or if it should offer traditional function NAME(ARGS) { } too. Arrow functions don't provide constructor behavior, so the risk of offering traditional functions is that they could be called from SES with new, which might cause surprises (Jessie forbids both new and this, so Jessie code couldn't provoke this, but it could happen if SES code is given access to a Jessie-defined object). The fact that Jessie rejects this might limit the surprises to ones that the SES code could have built anyways.

I'll leave it to @erights to fill in the details.

@erights
Copy link
Contributor

erights commented Nov 15, 2018

Another hazard of functions vs arrow functions. A Jessie module should only be able to export objects that have no transitively reachable mutable state, i.e., are pure in the sense of Wyvern's module system. With arrow functions, we can require code such as

export const foo = def((...args) => body);

For function functions, we'd like to be able to write

export function foo(...args) { body }
def(foo);

however, in the context of cyclic imports, foo could be accessible before it is frozen. The safe alternative

export const foo = def(function(...args) { body });

is substantially more verbose than either. Programmers (including myself) will be esthetically repelled by code containing that last form. If Jessie does have function functions, we need to find a better way to export a safe one.

@erights
Copy link
Contributor

erights commented Jan 4, 2019

I am about to transfer this issue from the SES repository to the Jessie repository. Issue transfer is a Github beta feature and I've never done it before, which is why I'm making this note first.

@erights erights transferred this issue from Agoric/SES Jan 4, 2019
@erights
Copy link
Contributor

erights commented Jan 4, 2019

We are in the midst of designing better rules for writing modules to be used as pure modules. We will require only that the module is purifiable, i.e., that it becomes pure, if all of its imports are pure and all its exports are hardened. We assume that a purity-enforcing loader will do the harden calls on the exported values. As a result, code like

export function foo(...args) { body }

is perfectly fine code for a pure SES module without this module having to explicitly harden foo. By exporting foo, we get that effect for no further notation.

The remaining issue with allowing function in Jessie is whether a SES caller of a Jessie function can cause mischief by invoking it with new. I believe the answer is that allowing this causes no loss of security. All the mischief that the SES caller could do by these means, they can do anyway.

Given this, I think the right thing to do is to include function in Jessie. Since function is already included in the current Jessie grammar, I am closing this.

@erights erights closed this as completed Jan 4, 2019
@erights
Copy link
Contributor

erights commented Jan 4, 2019

Reopening. I forget that Jessie supports only default exports, so the reasoning above is flawed.

@erights erights reopened this Jan 4, 2019
@erights
Copy link
Contributor

erights commented Jan 10, 2019

This is very strange. In email I got notified of two messages in this thread from Michael Fig, sent at 8:20pm and 8:21pm Jan 9 2019. But when I refresh this github thread page in my browser, the last message I see in this thread is one from me six days earlier.

Any ideas?

@erights
Copy link
Contributor

erights commented Jan 10, 2019

Now I see that Michael also posted these as #19 , so I'll answer there.

@endojs endojs locked and limited conversation to collaborators May 29, 2022
@michaelfig michaelfig converted this issue into discussion #83 May 29, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants