Conversation
|
This PR introduces default methods for traits: trait Foo a
@default_method: -> @
impl Foo Int64
main: -> (2).default_method! |
There is still a bug that needs a full empty line after the impl
|
We need a mecanism to allow |
Champii
left a comment
There was a problem hiding this comment.
Should add relevant issues from comments
e0fe5db to
3ac5028
Compare
3ac5028 to
446ce4f
Compare
|
Need doc |
|
What do you need me to review. The code or the idea. Also, what does a default method mean. As in that in the trait definition, we can declare a default implementation of a trait method that might be overridden? |
Principally the idea, but I would not refuse you picking a quick glance at the code, you might have some useful insights I'm missing
Yes, that's it. That way you can offer some basic logic that you can plug effortless into any type. |
|
I think we are all good for this one, waiting for your review before merging :) |
|
What is another POD type in Rock besides |
oraqlle
left a comment
There was a problem hiding this comment.
Looks Good!
Tested the old README.md stuff, had to get some of the updated versions such as the new impl but other than that it works.
Utilising the default methods is super clean and efficient. One thing I will point out for a future update is that when using the @ self symbol, the trait default trait declaration allows for a dot to preceed the method name as well as not allowing for it. ie. It doesn't enforce a dot or not a dot.
eg.
trait Foo a
@de: -> @print!This is the same as
trait Foo a
@de: -> @.print!We might want to enforce a particular syntax for consistency. Personally, I like the no-dot as it implies a sort-of auto dot.
You can find all the currently implemented primitive types of Rock at https://github.com/Champii/Rock/blob/master/src/lib/ty/primitive_type.rs#L4
Is there some stuff I forgot to update in the readme ?
This stuff is actually intended, and it will be difficult to enforce it. The primary concern is about the future macro system, that will have to make generic syntactic constructs that work for every identifier type. As we could write stuff like macro my_macro
$my_ident:ident =>
$my_ident.print!When applied to |
* Bump version * Update README to show the right version of llvm * Add the self returning method with `@->` * Add tests for self returning function * Add an embryo of documentation with mdbook * Documentation * Fix doc about struct * Doc * Add \0 as escaped char and generalize escaped char parsing (#125) * Add \0 as escaped char and generalize escaped char parsing * Inline parser variable in parse_char method * Readme * Readme * Escaped chars (#132) * Add \0 as escaped char and generalize escaped char parsing * Inline parser variable in parse_char method * Better unescaped handling * Fix escaped backslack and add tests * Restored string unescape * Fixed the `\0` escaped char * Doc * Introducing default trait methods (#128) * Introducing default trait methods * Allow for empty impl * Readme * Add tests * Allow for default method overriding * Add tests for default method overriding * Doc * Fix dot notation newline (#140) * Fix dot notation by restricting newline in dot notation when parsing an argument * Readme * Struct fields are no more reordered. (#138) * Struct fields are no more reordered. * Removed comment * Removed some old readme entry * Submodule parser errors (#137) * Subparser now fails when error * Transformed the module declaration error to failure * Fixed the diagnostic in submodule not showing
No description provided.