Re: Natural "for" Loop, using Plural / Singular transformations ??

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
30 May 2006 18:38:46 -0400

          From comp.compilers

Related articles
Natural "for" Loop, using Plural / Singular transformations ?? olivier.chatelain@gmail.com (2006-05-26)
Re: Natural "for" Loop, using Plural / Singular transformations ?? owong@castortech.com (Oliver Wong) (2006-05-30)
Re: Natural "for" Loop, using Plural / Singular transformations ?? dmaziuk@bmrb.wisc.edu (Dimitri Maziuk) (2006-05-30)
Re: Natural "for" Loop, using Plural / Singular transformations ?? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2006-05-30)
Re: Natural "for" Loop, using Plural / Singular transformations ?? tom@infoether.com (Tom Copeland) (2006-05-30)
Re: Natural "for" Loop, using Plural / Singular transformations ?? 148f3wg02@sneakemail.com (Karsten Nyblad) (2006-06-03)
Re: Natural "for" Loop, using Plural / Singular transformations ?? dot@dotat.at (Tony Finch) (2006-06-05)
Re: Natural "for" Loop, using Plural / Singular transformations ?? p_ludemann@yahoo.com (Peter Ludemann) (2006-06-11)
Re: Natural "for" Loop, using Plural / Singular transformations ?? jthorn@aei.mpg.de (Jonathan Thornburg) (2006-06-12)
Re: Natural "for" Loop, using Plural / Singular transformations ?? haberg@math.su.se (2006-06-12)
[3 later articles]
| List of all articles for this month |

From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups: comp.compilers
Date: 30 May 2006 18:38:46 -0400
Organization: cbb software GmbH
References: 06-05-083
Keywords: syntax
Posted-Date: 30 May 2006 18:38:46 EDT

On 26 May 2006 12:51:40 -0400, olivier.chatelain@gmail.com wrote:


> What about using Plural => Singular transformations to generate loop
> variables from name of lists?
>
> EXAMPLE:
>
> FOR dependency IN dependencies DO
> PRINT dependency.name
> END
>
> = depenendcies -generates-> dependency =
>
> FORALL dependencies DO
> PRINT dependency.name
> END
>
> The compiler would generate the "singular" loop variable "dependency"
> from the List "dependencies" (Plural).


Hmm, what about


for Arrays do
      for Arrays do
            print Cov (Array.Element, Array.Element)
                  -- Would it print the covariance matrix?
      end
end


The logical error is that the loop variable is not a property of the
iterated container. So you cannot derive its name from the container's name
alone. You could do it from the loop's name. For example:


Outer : for Arrays do
      Inner : for Arrays do
            print Cov (Inner.Item, Outer.Item)
                  -- This works
      end
end


But how is it better than the construct we have started from?


--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.