Skip to content
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

Use = rather than as for assigning column aliases in group and compute #24

Closed
julianhyde opened this issue Mar 22, 2020 · 1 comment
Closed

Comments

@julianhyde
Copy link
Collaborator

Morel should use = rather than as for assigning column aliases. Morel already uses = in records but it currently uses as in group and compute clauses.

Using as is inconsistent with uses of = elsewhere, and will be confusing when we implement Standard ML layered patterns (e.g. val x as (fst,snd) = (2, true)).

Currently we would write

from e in emps,
    d in depts
  where e.deptno = d.deptno
  group e.id + d.deptno as x, e.deptno
    compute sum of e.id as sumId;

but this would become

from e in emps,
    d in depts
  where e.deptno = d.deptno
  group x = e.id + d.deptno, e.deptno
    compute sumId = sum of e.id;

If you want an expression with =, you should enclose in parentheses, e.g.

from e in emps
group parity = (e.id mod 2 = 1) compute c = count

This is no great hardship; there are only automatic aliases for variables and field references, and e.id mod 2 = 1 is an expression, so you would have had to provide an alias anyway.

@julianhyde julianhyde changed the title Use '=' rather than 'as' for assigning column aliases Use = rather than as for assigning column aliases Mar 22, 2020
@julianhyde julianhyde changed the title Use = rather than as for assigning column aliases Use = rather than as for assigning column aliases in group and compute Mar 23, 2020
@julianhyde
Copy link
Collaborator Author

Fixed in 9219191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant