Ralf Hemmecke wrote:
> 
> Waldek,
> 
> The result is 16, if I put that in an .input file and read that file.
> But, honestly, I wouldn't have expected that.
> 
> Something like
> 
> foo
>      foo    <-- strange that this works here.
>    foo
>      foo 1
> 
> looks wrong to me. In particular the second foo.
> 
> I would be in favour of NOT accepting that input.

Well, from Aldor UG (skipping irrelevant cases):

o Consecutive lines indented the same ammount form a pile.
o The pile is enclosed in a SETTAB-BACKTAB pair if
    - the pile has more than one line
o A line is joined to the previous line if it is indented with respect to
     it, forming a new single line.
These rules are applied from the most indented lines back out to the least
indented lines.

So, single line are joined with previous lines, starting from
most indeted lines.  So after first step we get:

foo       foo
   foo    foo 1

And now there should be nothing strange about this.

> That would mean foo {foo} {foo {foo 1}} which looks wrong to my eyes.
> I never understood the piling rules and, in fact, I am rather unwilling 
> to learn them. Waldek's example looks unintuitive to me.

The example was _not_ intended to be intuitive, rather the
purpose was to show how the existing rules work and that
they lead to unintuitive result.

BTW: Why I looked at such pattern at all?  The problem is
that multiline piles insert parenthesis and semicolons
(in Aldor SETTAB, BACKTAB, and BACKSET) which in many
cases are problematic.  So the question is how to
organize sources to avoid (multiline) piles?  Of course
one may put everything on one long line or use line
continuation.  But single line is ugly and problematic
and line continuation sometimes is unwanted too (think
about data that should be read both by FriCAS and some
other program which does not recognize '_' as escape).
Next obvious thing to do is to arrange line into
indented pattern:

f
   f
       f
           1

but this easily leads to excessive indentation: for
n lines you use n indentation levels.  The pattern
I gave allows 2^n lines using only n indentation levels.

However, the real point of my message is that trying
to enforce "good style" by language restrictions is
pointless, rules may easily lead to worse code
(after all, one motivation for pile rules were to force
consistent indentation, but in appropriate circumstances
they force quite unintitve indentation pattern).
-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to