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

[RFC] Reflection #84

Open
mertyildiran opened this issue Dec 16, 2020 · 2 comments
Open

[RFC] Reflection #84

mertyildiran opened this issue Dec 16, 2020 · 2 comments
Assignees
Labels
feature request New feature or request
Projects

Comments

@mertyildiran
Copy link
Member

Implement the core library inspect to provide reflection capabilities:

import inspect
import math

num def multiply_these(num a, num b, num c)
    num r = a * b * c
    return r
end

print multiply_these(3, 4, 5) # Should print 60

# Information related
print inspect.parameter_count('multiply_these') # Should print 3
print inspect.parameter_types('multiply_these') # Should print ['num', 'num', 'num']
print inspect.return_type('multiply_these') # Should print ['num']
print inspect.decision_length('multiply_these') # Should print 0
print inspect.context('multiply_these') # Should print 'dev.kaos'
print inspect.module_context('multiply_these') # Should print 'dev.kaos'
print inspect.module('multiply_these') # Should print ''

# Call related
print inspect.call('multiply_these', [3, 4, 5]) # Should print 60
print inspect.call('sin', [30], 'math') # Should print 0.5
@mertyildiran mertyildiran added the feature request New feature or request label Dec 16, 2020
@mertyildiran mertyildiran self-assigned this Dec 16, 2020
@mertyildiran mertyildiran added this to To do in Chaos via automation Dec 16, 2020
@naltun
Copy link
Member

naltun commented Dec 16, 2020

inspect seems like it would work pretty great alongside a built-in debugger (eg. cdb).

@mertyildiran
Copy link
Member Author

@naltun yes, you're right. `inspect will be an important library to unveil the information about the language internal workflow and it will be required to write a debugger and intellisense like IDE tools for this language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
Chaos
  
To do
Development

No branches or pull requests

2 participants