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

need a way to get type of object #47

Open
edwadli opened this issue Nov 6, 2015 · 8 comments
Open

need a way to get type of object #47

edwadli opened this issue Nov 6, 2015 · 8 comments

Comments

@edwadli
Copy link
Owner

edwadli commented Nov 6, 2015

In the stdlib, we may find that we'll have to initialize an empty list of the some input list.

We can reuse the type keyword, or we can use Type keyword, so it looks like a function (when in reality it's a signal to the compiler to grab the type)

@kevin1 kevin1 added this to the Have a grammar milestone Nov 6, 2015
@kevin1 kevin1 removed this from the Have a grammar milestone Dec 1, 2015
@edwadli
Copy link
Owner Author

edwadli commented Dec 1, 2015

How about a new keyword (eg, new my_var) that gives u an empty list, or initted user type, or some default value for other types

@kevin1
Copy link
Collaborator

kevin1 commented Dec 1, 2015

Can you give an example of the use case?

@edwadli
Copy link
Owner Author

edwadli commented Dec 1, 2015

fun Pop my_list = (
  x = new my_list
  i = 0
  for item in my_list do (
    if i == (Length my_list - 1) then ()
    else (x = x . [item])
    i = i + 1
  )
  x
)

@edwadli
Copy link
Owner Author

edwadli commented Dec 1, 2015

fun Pop my_list = (
  x = new my_list
  for i in Range 0 (Size my_list - 1) do x = x . [item]
  x
)

@kevin1
Copy link
Collaborator

kevin1 commented Dec 1, 2015

That one we can implement by making a function to delete at an index.

I think we should put off implementing this feature until we actually need it.

@edwadli
Copy link
Owner Author

edwadli commented Dec 1, 2015

do u mean in support cpp

@kevin1
Copy link
Collaborator

kevin1 commented Dec 1, 2015

Yeah — #107 — and then it can be

fun Pop a = ArrayDelete a ((ArrayLength a) - 1)

@edwadli
Copy link
Owner Author

edwadli commented Dec 1, 2015

ok sounds good to me

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

2 participants