Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented Nov 17, 2019

Before, these yielded a syntax error.

@thekid
Copy link
Member Author

thekid commented Nov 17, 2019

Comments are not retained inside the emitted code, so this may become a source of confusion if people use XP-style annotations (e.g. #[@test]) instead of the Hacklang-inspired <<test>>). Previously, there was at least a syntax error, so people would notice.

Handling this could be done by:

  • ...storing them inside a doc comment (and extending XP reflection to support this), which would require new XP7, XP8 and XP9 releases to retain BC
  • ...reparsing them into << ... >>-format, which is a bit tricky because of parameter annotations, which exist inside as function-level comments as @$param: annotation. ✅
  • ...raising a parse error with a dedicated message
  • ...retaining these comments and emitting them inside the generated source code

@thekid
Copy link
Member Author

thekid commented Nov 23, 2019

Performance

Before:

$ XP_RT=7.4 xp test src/test/php/
# ...
♥: 577/577 run (0 skipped), 577 succeeded, 0 failed
Memory used: 7818.67 kB (7876.94 kB peak)
Time taken: 0.226 seconds

After:

$ XP_RT=7.4 xp test src/test/php/
# ...
♥: 592/592 run (0 skipped), 592 succeeded, 0 failed
Memory used: 7965.44 kB (8023.70 kB peak)
Time taken: 0.228 seconds

Code

Before:

$ cloc-1.82.pl src/main/
      51 text files.
      51 unique files.
      10 files ignored.

github.com/AlDanial/cloc v 1.82  T=0.20 s (251.3 files/s, 22685.6 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PHP                             50            536            684           3293
-------------------------------------------------------------------------------
SUM:                            50            536            684           3293
-------------------------------------------------------------------------------

After:

$ cloc-1.82.pl src/main/
      51 text files.
      51 unique files.
      10 files ignored.

github.com/AlDanial/cloc v 1.82  T=0.23 s (214.1 files/s, 19483.2 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
PHP                             50            540            684           3327
-------------------------------------------------------------------------------
SUM:                            50            540            684           3327
-------------------------------------------------------------------------------

...a difference of +34 lines

@thekid
Copy link
Member Author

thekid commented Nov 23, 2019

Handling the key/value pair syntax requires an additional 27 lines of code, and a bit of look-ahead magic. Once xp-framework/rfc#335 is fully implemented, this can be removed.

@thekid thekid merged commit 5162409 into master Nov 23, 2019
@thekid thekid deleted the feature/hashtag-comments branch November 23, 2019 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants