Add verbatim string literals '...' #5
Labels
No Label
enhancement
in progress
on deck
uncertain
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Blocks
Reference: glen/fostr#5
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This opens a host of other questions:
How to allow the ' character to occur in such a literal? Answer: Don't, since we will end up adding ""-strings with escape sequences anyway, and those can have either ' or " (via
\"
) in them.Semantics of String + String? It seems this should perhaps be concatenation, but on the other hand, there's reason to use application for concatenation, namely that then string interpolation becomes fairly moot, in that it's not much easier to write
"The sum of {a} and {b} is {a+b}." than 'The sum of 'a' and 'b' is '(a+b)'.'
Semantics if any of Int + String, etc. ?
Do we need to type things to be able to generate code for sums?
But if application is concatenation, how do we index a string to get characters and substrings and such? We were planning to use application for indexing of arrays and finite maps (makes perfect sense to think of them as kinds of functions).
I think it's ok to lose the indexing semantics for application, but we need a nice syntax for indexing/slicing. Perhaps @ operator, although then there's a question of what to do for namespacing, as I was also thinking of identifiers of the form fred@module. I'd be worried about overloading between these two.
I think fostr should go with string @ 3:6, and maybe use ~ for namespaced identifiers, e.g. fred~module.
And the plan now is to use ++ for string concatenation, rather than overloading +, and
for strings s, s 'fred' will be a shorthand for s ++ fred, whereas for other collections c, c 5 will be a shorthand for c @ 5.
glen referenced this issue2021-02-12 00:31:02 +00:00
Todos on this issue:
See if I can make sense of Ivo Wilms' wrapper functions in SlackDebug Haskell code generation: Gets() with typed itemDo a documentation PR on stratego for the help that was provided with syntaxWork out the case of typing a sequenceAnswer: string literals must be contained in a single line because of the offside
rule; apparently the internal whitespace characters count as characters in the line, and so trigger the offside.
Actually do the Haskell code generation in both ways:
A) Put a hashtable on every node and populate it with preamble and value and such,
then use the values from the hash at the top.
B) Make a dynamic rule Preamble: () -> string that is going to start out giving the empty string, and just accumulate in the value be resetting the rule. Basically just use the dynamic rule as a global variable.
Then ask on Slack which is "better".
New approach:
A) Stick preamble lines onto a rule Preactions : () -> String, just constantly appending to the string.
B) Have the rule pass back just the value expression
C) Iterate with bottomup-para so the original expression is available as well as the value expression.
Hopefully that will allow everything to be expressed as easily as possible, with
just the minimal amount of propagation code.