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

added macro for imports: 予观夫「列經」胜状,在「遍施」、「篩剔」、「左併」三湖。 #458

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kaiyuan01
Copy link
Contributor

吾嘗觀「「列經」」之書。方悟「遍施」「篩剔」「左併」之義。

或云「「予观夫「甲」胜状,在「乙」、「丙」、「丁」三湖」」。
蓋謂「「吾嘗觀「甲」之書。方悟「乙」「丙」「丁」之義」。

予观夫「列經」胜状,在「遍施」、「篩剔」、「左併」三湖。

吾嘗觀「「列經」」之書。方悟「遍施」「篩剔」「左併」之義。

或云「「予观夫「甲」胜状,在「乙」、「丙」、「丁」三湖」」。
蓋謂「「吾嘗觀「甲」之書。方悟「乙」「丙」「丁」之義」。

予观夫「列經」胜状,在「遍施」、「篩剔」、「左併」三湖。
@kaiyuan01
Copy link
Contributor Author

Follow the syntax in

予观夫巴陵胜状,在洞庭一湖.

岳阳楼记 (作者:范仲淹)

@kaiyuan01
Copy link
Contributor Author

Any idea why the build failed with:

TypeError: Cannot read property 'length' of undefined

?

@LingDong-
Copy link
Member

LingDong- commented Dec 31, 2019

Hi @kaiyuan01 ,

Thanks for the PR. However, a couple of things:

  • You are missing a at the end of蓋謂「「吾嘗觀「甲」之書。方悟「乙」「丙」「丁」之義」。. That is one of the reasons why it doesn't compile. Please double check your code before submitting any PR.

  • Currently import statements cannot be patched by macros. They are used by the processor to figure out which files to extract macros from, and having them as part of a macro confuses the preprocessor. I can see a way around this, will investigate later. Thanks for bringing this up.

  • We all love 岳陽樓記, but I don't think your addition adds much to the illustrative purpose of the example. Moreover, I think this usage is showing an anti-pattern. We would hope that users utilize macros to make their code more clear and concise, while your example is doing the exact opposite: obfuscating the import statement into something irrelevant. Technically this is something cool the user can do if they choose to, but we would like to refrain from advocating it in the examples :)

Thanks again for your understanding.

@kaiyuan01
Copy link
Contributor Author

Sorry I was on another computer which was not able to run gitpod due to network issues. This is more like an example to show how macro works (it can be more concise, or more verbose if we want to attract non-programmers :-) )

@kaiyuan01
Copy link
Contributor Author

Hi @kaiyuan01 ,

Thanks for the PR. However, a couple of things:

  • You are missing a at the end of蓋謂「「吾嘗觀「甲」之書。方悟「乙」「丙」「丁」之義」。. That is one of the reasons why it doesn't compile. Please double check your code before submitting any PR.
  • Currently import statements cannot be patched by macros. They are used by the processor to figure out which files to extract macros from, and having them as part of a macro confuses the preprocessor. I can see a way around this, will investigate later. Thanks for bringing this up.
  • We all love 岳陽樓記, but I don't think your addition adds much to the illustrative purpose of the example. Moreover, I think this usage is showing an anti-pattern. We would hope that users utilize macros to make their code more clear and concise, while your example is doing the exact opposite: obfuscating the import statement into something irrelevant. Technically this is something cool the user can do if they choose to, but we would like to refrain from advocating it in the examples :)

Thanks again for your understanding.

@LingDong- Thanks for the help. Was the second issue fixed? Just wondering what failed the current tests.

@LingDong-
Copy link
Member

  • Second issue is not fixed yet, will look into it
  • I maintain the opinion in my third point
    Thanks!

@kaiyuan01
Copy link
Contributor Author

I made the change as suggested. You may consider merging it once you fix Issue #2.

@LingDong-
Copy link
Member

Hi, sorry for the delay, the issue of inability to use macros for import statements has been fixed in my newest commit 55d2885.

However there is one more problem with your code, that is, a macro cannot end with an identifier. If it ends with an identifier like 得「乙」「丙」「丁」於「甲」, the finding-replacing wouldn't know where to end. See #440 for details.

I recommend that you change it to something like this:

...

或云「「得「乙」「丙」「丁」於「甲」焉」」。
蓋謂「「吾嘗觀「甲」之書。方悟「乙」「丙」「丁」之義」」。

...

得「遍施」「篩剔」「左併」於「「列經」」焉

...

Also please drop the 三湖 etc comment. Thanks!

@Xuanmizhen
Copy link
Contributor

想法挺好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants