The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

victor.savkin (1) [Avatar] Offline
#1
Page 219:

One of guard clauses is:
if (!astNodes || ) return

This line of code can't be compiled. Probably it should be something like:
if (!astNodes) return OR if (!astNodes || !sourceUnit) return

Page 218:

@GroovyASTTransformationClass ([examples.MainTransformation])
value is String[], not Class[], so it can't be compiled.


Some suggestions:
1. It'd be great to see more about compile phases. Just a few paragraphs per phase describing what Groovy compiler adds to AST would be enough. In my view, current description of each phase (about a sentence per phase) is too short and doesn't cover the difference between CONVERSION, SEMANTIC_ANALYSIS, CANONICALIZATION, INSTRUCTION_SELECTION.

2. Also, it would be nice to see some explanation of guard clauses. MainTransformation (from page 21smilie can be applied only to methods. Why do we check that we have 2 elements in astNodes and the second one is MethodNode? I don't see why we are doing it.

Thanks,
Victor
HamletDRC (6) [Avatar] Offline
#2
Re: Can't Compile Code Snippets in Chapter 9
Thanks for the feedback. I will update the chapter with this info.

The compiler phase descriptions is a tough one, because we're already at 54 pages for the chapter. I'll see what we can do though.