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
java doc support #29
java doc support #29
Conversation
aab4f2b
to
8bb9632
Compare
Note! Javadoc support implemented only for class, interface and method definitions. |
Why not make a doc comment just be syntactic sugar for a modifier method invocation? /** some comment */
def foo
end is equivalent to doc(" some comment ",
def foo
end
) Likewise /** some comment */
protected def foo
end is equivalent to doc(" some comment ",
protected(
def foo
end
)
) I like having doc-comments being part of the AST. This has advantages for automatically generated code by Mirah macros: The macros which autogenerate methods could also autogenerate appropriate doc code. However, it is not clear why we should choose JavaDoc in particular. Other candidates are, for example, YARDoc and Doxygen. For the syntax of doc comments: Should we use Java-style "/*.../"? Should we use Ruby-style "# ... \n"? Should we use a different style? Should it be possible to nest comments? Should Mirah have multiline-comments at all? |
I agree, that it's questionable what should mirah use for doc comments. I prefer Java Doc for it's extended support in tools and IDE and plan to provide an integration in mirah compiler. I'm afraid it would be not that easy to integrate YARDoc as mirah have different than ruby syntax. |
Had a quick look at Doxigen. It seems that doxygen integration could be implemented in the same way as java doc. Generate java stubs and pass it to doxigen. |
Implemented pull request in mirah mirah/mirah#381 |
Once again: Why not make a doc comment /** foobar */ ... just syntactic sugar for a macro invocation doc(" foobar ", ...) ? This solution solves all issues with macros which return methods or classes, such as |
That's why I do not like using macro for specifically for java doc. As for modifiers - I still think that having them part of the language is more correct way than macros.
For me it was faster solution to have modifiers in AST to fix some of them :). synchronized attr_reader a:int
private synchronized attr_writer a:int Currently it's not supported with modifiers either, but could be implemented. |
I'm not suggesting against the What I think is problematic is pushing Mirah features directly into the syntax. Pushing features into the syntax makes them inaccessible to meta-programming.
Sure
The default
I would keep the syntactic sugar of multi-line comments, of course.
It depends on the IDE. Most IDEs seem to be not meta-programming friendly. However, Mirah is a meta-programming language. That's why I'm intervening here. Having JavaDoc or something like this is a good thing, but not at the expense of making Mirah a non-meta-programming language. So the IDE has 2 options:
It is clear that the latter version takes more time. However, once we have recompilation support in the compiler (the compiler detects which files need to be recompiled and only compiles these, re-using the already compiled macros defined in other files), this shouldn't be a practical problem any more.
Sure, but this makes no difference, Whether we have
Maybe there is a misunderstanding here: The
You are actually mistaken. Macro chaining works fine. For example, protected abstract class Foo
protected synchronized def foo
end
end is perfectly valid and compiling Mirah code, as is class Foo
protected attr_accessor foo:int
end Yes, currently, both the type-inference and the macro expansion are done in the same phase, and the type-inference-macro-expansion superphase is applied twice, once before applying a macro on a ClassDefinition and once after applying the macro on a ClassDefinition. This should be fixed, but I haven't doing that so far, as this a quite far-reaching change and thus I expect something to break. But if the pain of not-fixing is bigger than the pain of fixing, then maybe we should decide whether the typer should run before or after applying macros, and then implement this fix.
Sure, macros take more time when compiling. But they save time when typing. This is the tradeoff decision made for Mirah.
I do not understand this item, apart from that a macro-less Mirah would have easier IDE support. (However, a macro-full Mirah produces less need for having an IDE in the first place, because repeating code could be optimized away – using macros...)
Oh, you could have it like it is done for the attr_writer a:int, b:String are currently allowed. So the discussion seems to boil down to whether Mirah macros (and thus meta-programming) are first class features of Mirah or not, whether Mirah should evolve away from macros (and thus away from the ability of meta-programming) or not. IMHO, Mirah macros (and thus meta-programming) are the killer feature over Java, and thus should be employed generously. Because we seem to have a stalemate here, I'd like to solicit other opinions. @baroquebobcat , @headius ? |
Regarding macro chaining, you are right. It really works, sorry to be mistaken. |
This pull request provides optional JavaDoc Nodes in mirah AST and whitespace and comments tokenization in mirah lexer.