Right - covering your points:
idea that if the string contents are not indented then no indentation is expected or required
Thats not quite it - the trigger for indentation being stripped is that the line after the opening line is indented exactly one level more than the opening line...
this serves as an implicit trigger that indentation removal (on all lines) to that level is to be done - as I noted its a convenience for what I envisage as the most common
formatting choice.
You can suppress the indentation auto removal by merely adjusting the first line indentation (back to flush left or indented same as opening line or indented more to the right)
If it turns out that you actually want the indentation given by the natural one level in indentation you can get that with the patch using the alternative (+|) processing if not use
the '|' edge bars on edges within content
e.g.
- Code: Select all
assert R'+|
indented
indented' == r'\tindented\n\tindented'
..
Actually it could be setup so that explicit is better so could support another option to explicitly enable/disable the auto indent removal (see below...)
start string on following line
yes but for short multiline strings it adds an extra unused code line which isnt part of the resulting formatting ( 2 lines in result from 3 lines in code)
... I made up a page of examples to see what it looked like.. It seemed to me the skewedness is only really apparent for a smallish number of following lines ( 2-6) - for 2 (opening line + 1 following) its not really apparent and after about 5-6 after the opening line the formatting of the following lines is what the eye is drawn to (YMMV).
The other point with this is that thats what the '+|' option setting syntax on the first line gives you anyway
rawness and multilineness
I'm conflating this because this isnt a implementation/proposal for all the existing varieties of single string lines supporting multiline - its specifically for the equivalent of a multiline raw string
given that - for (at least) a raw string the only difference single vs multiline is capturing the embedded newline ( and some parsing issues (:-))
i.e the raw string should have supported multiline/embedded newline from the get-go
(as a comparison consider the example of some imaginary string literal variants ; one that supports \t for tab char insertion expansion but doesnt allow an embedded Tab character and one that doesnt support either - seems an artificial and unnecessary distinction right?)
triple quotes for multiline strings
Yeah well as already noted my preference would be to fold the
- Code: Select all
R'...'
into the existing raw string syntax
- Code: Select all
r'...'
.
The caps R is just to indicate that its still a raw string
Hmm are you considering that supporting the existing string literals syntax in multiline versions is a reasonable way to go ?
(in both
- Code: Select all
" and '
delimited variants )
- Code: Select all
r""" ...""" # multiline raw vs r""
"""..." # multiline string (with and without subs vs "" single line
ns"""...""" # non substitutable multiline vs ns""
sharp""" ...""" # multiple csharp codelines vs sharp''
c""".....""" # character stream ((:-) vs c'.'
that seems a little .... multitudinal
R'+| syntax
its actually
R'
syntax - like
r'', ns'', sharp""
exactly as arcane and symbolic as the existing string literals
- the 'R' is cos its like r'' ( raw) but bigger ( and r'' is already used which brings us back to the conflation thing above)
The '+|\n' part is an option switch that sez we want to so some different/additional processing from the default (simpler) processing
= '+' turnOn '|' bar formatting processing
I dont really have much of a preference on how internal option changes could be indicated ( see patches for trace expr and position suppression) - thats as simple and
obvious as any
e.g for explicitly specifying indentation auto removal any of : '+ir', -i, -indentation, .... on opening line.
and I think its preferable to a entirely new syntax that does the same thing ( as multiline raw) with some additional post processing
advantage VS the single quoted line continued proposal
- explicit embedded newline ( within the terminators) - raw - whats there is what you get
- No line continuation hackery
- '|' bars are optional either side
- easy to explain, obvious to see result (less visual clutter)
- easy to implement
--Re triggering off use of opening line vs stepping to after newline for content for indent auto prune
yeeees maybe I'll have to think about that a bit more....
OTTOMH tho' it precludes any sort of option settings and
for a raw string version it requires a bit of explanation as to why a raw string is having some ( the first) newline
suppressed (like the explanation around '|' processing)
Lets take the varying newline thing to a new topic.