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

Add a String argument to save #29

Open
emilaxelsson opened this issue Oct 31, 2012 · 2 comments
Open

Add a String argument to save #29

emilaxelsson opened this issue Oct 31, 2012 · 2 comments

Comments

@emilaxelsson
Copy link
Member

This could be used in the back end to identify the saved value (e.g. used as the variable name).

@emwap
Copy link
Member

emwap commented Nov 2, 2012

How do we make sure that the names are unique. I suggest we use one of the schemes below:

  1. v_name1
    • looks weird
  2. name_v1
    • straight forward
  3. name1
    • nicest name
    • potentially not unique if name is one of ["e", "v", "x", "len"]
  4. name
    • exactly what the user wanted
    • requires analysis to make sure name is unique

I'm leaning towards number 3 since it has references to both the name and the variable id for debugging.

@pjonsson
Copy link
Member

pjonsson commented Nov 2, 2012

Consider borrowing the idea of how variables are treated from GHC. A variable is record of a string (what the user wrote) that doesn't really carry any meaning and a unique identifier that is the sole identification of the variable. When fresh variables are created from old variables they simply get a new unique identifier but keep their string, so the user (or compiler developer) can figure out that meanVal274 is somehow related to the mean value variable inside the now inlined mean-value function.

General pretty printing would just print meanVal and let the user read the program with the scoping rules in mind. Debug pretty printing would print meanVal_274 or similar. The compiler would identify the variable by its unique, in this case 274.

This scheme allows you to use option 3 with an even nicer name without the drawback of uniqueness problems.

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

No branches or pull requests

3 participants