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

Variables #21

Open
vshesh opened this issue Dec 14, 2016 · 1 comment
Open

Variables #21

vshesh opened this issue Dec 14, 2016 · 1 comment

Comments

@vshesh
Copy link
Owner

vshesh commented Dec 14, 2016

Try having to paste an element like:
P[idea](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgNDggNDgiIGZpbGw9IiMwMDAiID48Y2lyY2xlIGZpbGw9IiNGRkY1OUQiIGN4PSIyNCIgY3k9IjIyIiByPSIyMCI+PC9jaXJjbGU+PHBhdGggZmlsbD0iI0ZCQzAyRCIgZD0iTTM3LDIyYzAtNy43LTYuNi0xMy44LTE0LjUtMTIuOWMtNiwwLjctMTAuOCw1LjUtMTEuNCwxMS41Yy0wLjUsNC42LDEuNCw4LjcsNC42LDExLjMJYzEuNCwxLjIsMi4zLDIuOSwyLjMsNC44VjM3aDEydi0wLjFjMC0xLjgsMC44LTMuNiwyLjItNC44QzM1LjEsMjkuNywzNywyNi4xLDM3LDIyeiI+PC9wYXRoPjxwYXRoIGZpbGw9IiNGRkY1OUQiIGQ9Ik0zMC42LDIwLjJsLTMtMmMtMC4zLTAuMi0wLjgtMC4yLTEuMSwwTDI0LDE5LjhsLTIuNC0xLjZjLTAuMy0wLjItMC44LTAuMi0xLjEsMGwtMywyCWMtMC4yLDAuMi0wLjQsMC40LTAuNCwwLjdzMCwwLjYsMC4yLDAuOGwzLjgsNC43VjM3aDJWMjZjMC0wLjItMC4xLTAuNC0wLjItMC42bC0zLjMtNC4xbDEuNS0xbDIuNCwxLjZjMC4zLDAuMiwwLjgsMC4yLDEuMSwwCWwyLjQtMS42bDEuNSwxbC0zLjMsNC4xQzI1LjEsMjUuNiwyNSwyNS44LDI1LDI2djExaDJWMjYuNGwzLjgtNC43YzAuMi0wLjIsMC4zLTAuNSwwLjItMC44UzMwLjgsMjAuMywzMC42LDIwLjJ6Ij48L3BhdGg+PGNpcmNsZSBmaWxsPSIjNUM2QkMwIiBjeD0iMjQiIGN5PSI0NCIgcj0iMyI+PC9jaXJjbGU+PHBhdGggZmlsbD0iIzlGQThEQSIgZD0iTTI2LDQ1aC00Yy0yLjIsMC00LTEuOC00LTR2LTVoMTJ2NUMzMCw0My4yLDI4LjIsNDUsMjYsNDV6Ij48L3BhdGg+PGc+CTxwYXRoIGZpbGw9IiM1QzZCQzAiIGQ9Ik0zMCw0MWwtMTEuNiwxLjZjMC4zLDAuNywwLjksMS40LDEuNiwxLjhsOS40LTEuM0MyOS44LDQyLjUsMzAsNDEuOCwzMCw0MXoiPjwvcGF0aD4JPHBvbHlnb24gZmlsbD0iIzVDNkJDMCIgcG9pbnRzPSIxOCwzOC43IDE4LDQwLjcgMzAsMzkgMzAsMzcgCSI+PC9wb2x5Z29uPjwvZz48L3N2Zz4=) over and over again.

It's no fun. First, it's not fun to have to do copy/paste, and second, it's extremely aesthetically disgusting to have a huge block (or even a semi large link) littering up the document. It would be better to allow variables in the syntax. This would have to be a feature of the parser directly, not a "component" itself, because how could the parser know to substitute things afterwards? Basically some kind of preprocessor.

There would have to be some way of describing variables, and separating them from the rest of the document.

@vshesh vshesh added this to the 0.2.0 milestone Dec 14, 2016
@vshesh
Copy link
Owner Author

vshesh commented Dec 16, 2016

One nice syntax might be ${variable} but as soon as variables enter the picture we get some problems:

  1. variables defined in terms of other variables - which anyone (especially me as a programmer) would want. That's the whole point of variables, anyway - being able to define higher orders of abstraction on top of the ones that we already have. That means that we have to do something like macroexpand to completely spit out the final component.

    • this isn't so bad, so long as it's just text replacement. We can compute the expanded version of each "variable" (which is now acting like a macro) once, and then do all the replacements in the document as necessary. Easy to implement with memoization.
  2. Taking parameters - effectively now switching from writing variables to fully writing macros in glue language - not sure at all how this would look. Pretty soon, I would be writing my own coding language! Also, like with Lisp, the question "where should I make this change - in a macro, or in the python component descriptions?" will always continue to exist. I feel like it's easiest to write the python components rather than create this whole mess with macros, although text replace variables would still be a good feature.

So in short, don't turn this into a P/L assignment: just force everyone to write scripts where they don't want text replacement. And it's okay for the text replacement to use other variables, but it should be seen as a stopgap for a component that someone should consider writing on the python side.

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

No branches or pull requests

1 participant