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

Short-hand to append fields to a record #61

Open
julianhyde opened this issue Aug 30, 2021 · 1 comment
Open

Short-hand to append fields to a record #61

julianhyde opened this issue Aug 30, 2021 · 1 comment

Comments

@julianhyde
Copy link
Collaborator

Add a short-hand to the language append fields to a record. For example, given

val emps = [
   {comm=0.0,deptno=20,empno=7369,ename="SMITH",hiredate="1980-12-16",
    job="CLERK",mgr=7902,sal=800.0},
   ... ]
: {comm:real, deptno:int, empno:int, ename:string, hiredate:string, job:string, mgr:int, sal:real} list;

suppose we wish to add a new column remuneration = comm + sal. Currently we would define a 'view' function

fun emps2 () =
  from e in emps
    yield {e.comm, e.deptno, e.empno, e.ename, e.hiredate, e.job,
      e.mgr, e.sal, remuneration = e.sal + e.comm};

but syntactic sugar such as the following would be helpful:

fun emps2 () =
  from e in emps
    yield {e.*, remuneration = e.sal + e.comm};
@julianhyde
Copy link
Collaborator Author

julianhyde commented Sep 1, 2021

In order to derive a type for {e.*, remuneration = e.sal + e.com} we will need to add row polymorphism to our type system.

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