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

Object.createFrom() #539

Merged
merged 10 commits into from
Oct 12, 2022
Merged

Object.createFrom() #539

merged 10 commits into from
Oct 12, 2022

Conversation

Jason2605
Copy link
Member

Well detailed description of the change :

This PR adds a new module Object that allows us to retrieve class references via strings or objects to be created via strings rather than always having a reference to the class.

Type of change:

  • New feature

Housekeeping

  • Tests have been updated to reflect the changes done within this PR (if applicable).

  • Documentation has been updated to reflect the changes done within this PR (if applicable).

@Jason2605 Jason2605 added the enhancement Implementation of a new feature label Oct 10, 2022
@Jason2605 Jason2605 self-assigned this Oct 10, 2022
```cs
class Test {}

Object.getClassRef("Test").unwrap(); // <Cls Test>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an easy way to get the name of the class from an object? I know we have a getAttributes method but I don't believe it includes the name of the class. That might be a nice addition so this can be even more dynamic.

Copy link
Member Author

@Jason2605 Jason2605 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say class name, do you mean an actual reference to the class or do you mean the string representation of the class name?

For example, if you already have the object you can get the class reference via: https://dictu-lang.com/docs/classes/#_class

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string representation of the class name.

Copy link
Member Author

@Jason2605 Jason2605 Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah there's currently no way to turn a class reference into a string'd name. We could add a _name attribute similar to _class to classes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be cool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be added as part of #543

Now it would be:

class Test {}

print(Test._name);
print(Test()._class._name);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

@Jason2605 Jason2605 merged commit 5b6bd4f into develop Oct 12, 2022
@Jason2605 Jason2605 deleted the feature/object_from branch October 12, 2022 12:55
@Jason2605 Jason2605 mentioned this pull request Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Implementation of a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants