[rfc-i] sourcecode indentation

brian.e.carpenter at gmail.com (Brian E Carpenter) Sun, 14 February 2016 22:01 UTC

From: brian.e.carpenter at gmail.com (Brian E Carpenter)
Date: Mon, 15 Feb 2016 11:01:29 +1300
Subject: [rfc-i] sourcecode indentation
In-Reply-To: <B8813042-3C6C-4653-9A3A-AAA3B2A68936@att.com>
References: <666F9FC6-BF2D-4827-B24A-20A8CCCC9F00@att.com> <F0D416DA-2C0F-4E11-B62C-7B9788796102@vpnc.org> <56BFA2E7.8070400@gmail.com> <56BFA781.10709@alum.mit.edu> <B8813042-3C6C-4653-9A3A-AAA3B2A68936@att.com>
Message-ID: <56C0F939.4040709@gmail.com>

Top posting for simplicity: yes, if there is insufficient
space to perform indenting or outdenting, I think that
throwing an error is absolutely the right thing to do
for source code.

   Brian

On 15/02/2016 08:53, HANSEN, TONY L wrote:
> On 2/13/16, 5:00 PM, "rfc-interest on behalf of Paul Kyzivat" <rfc-interest-bounces at rfc-editor.org on behalf of pkyzivat at alum.mit.edu> wrote:
> 
> 
>> On 2/13/16 4:40 PM, Brian E Carpenter wrote:
>>> On 14/02/2016 09:56, Paul Hoffman wrote:
>>>> On 12 Feb 2016, at 15:52, HANSEN, TONY L wrote:
>>>>
>>>>> A better example of outdent would be
>>>>>
>>>>> <sourcecode indent="-4">
>>>>>   foo
>>>>>     bar
>>>>>       baz
>>>>> </sourcecode>
>>>>>
>>>>> which would generate:
>>>>>
>>>>> <pre class="sourcecode">
>>>>> foo
>>>>> bar
>>>>>   baz
>>>>> </pre>
>>>>>
>>>>> in the HTML format.
>>>>>
>>>>> A more common variation might be where the input is coming from elsewhere and you have no control over the indentation used
>>>>> there:
>>>>>
>>>>> <sourcecode indent="-4" src="http://URL to the source code"/>
>>>>>   or
>>>>>
>>>>> <sourcecode indent="16" src="http://URL to the source code"/>
>>>>>
>>>>> The use case for this is very specific, but probably not something that would get used often.
>>>>>
>>>>> If you think you would find it useful, please speak up.
>>>>
>>>> I will speak up against this idea. For sourcecode where indentation is important, seeing an example at the left margin might
>>>> cause the reader to think that the code is in fact not indented. Your example above is a classic one: someone seeing that text
>>>> would assume that "foo" and "bar" are at the same level when they are not. I would prefer not to have the RFC format have a
>>>> display hinting mechanism that could be used to make examples harder to interpret.
>>>
>>> It's worse than that. In Python, it can invalidate the example completely.
>>>
>>> if whatever:
>>>      this
>>> that
>>>
>>> is very different from
>>>
>>> if whatever:
>>>      this
>>>      that
>>>
>>> but indent="-4" would reduce them both to
>>>
>>> if whatever:
>>> this
>>> that
>>>
>>> which is invalid syntax. It's a dangerous toy, in other words.
>>
>> Agreed that is dangerous. But negative indent could be OK if it just 
>> generates an error if there isn't sufficient whitespace to do the 
>> outdent completely.
> 
> I would actually prefer an error too if there is insufficient whitespace to do the outdent completely.
> 
> This,
> 
>   If whatever:
> 	This
> 
> Would generate an error for any indent < -2.
> 
> 
>> But what does negative indent do if there are tabs at the beginning of
>> the text?
> 
> 
> This question is broader than indent and outdent, as we don't currently allow tabs anywhere in the XML source.
> 
> 	Tony Hansen
> _______________________________________________
> rfc-interest mailing list
> rfc-interest at rfc-editor.org
> https://www.rfc-editor.org/mailman/listinfo/rfc-interest
>