comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: Re: advent of code day 11
Date: Sat, 12 Dec 2020 12:27:44 -0800	[thread overview]
Message-ID: <86bleypy67.fsf@stephe-leake.org> (raw)
In-Reply-To: b4611f34-d553-4f7c-806a-c799cad8cc0bn@googlegroups.com

John Perry <john.perry@usm.edu> writes:

> On Friday, December 11, 2020 at 11:08:00 AM UTC-6, Stephen Leake wrote:
>> mildly interesting; variation on Conway's Game of Life. 
>
> I thought it would be clearer to use references to switch from one
> chart to the other, but I had trouble doing that last night. Now I can
> get it this way:
>
>    Source: Chart_Array renames Chart1;
>    Result: Chart_Array renames Chart2;

A 'renames' declaration creates a _static_ name for the object that is
the result of the expression; the expression is evaluated once when the
'renames' declaration is evaluated. When the name is used, it is the
same as any other object name.

>    while Changed loop
>
>       Perform_Round( Source => Source , Result => Result , ... );
>       declare Tmp: Chart_Array renames Source;

'Tmp' is evaluated each time around the loop, but since the global
Source is static, it always has the same value of Chart1.

>       begin Source := Result;

This does not revaluate the expression for global Source; it uses the
global Source name to determine where to store a copy of Result.

-- 
-- Stephe

      parent reply	other threads:[~2020-12-12 20:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 17:07 advent of code day 11 Stephen Leake
2020-12-11 18:24 ` John Perry
2020-12-11 19:07   ` Jeffrey R. Carter
2020-12-11 19:29   ` gautier...@hotmail.com
2020-12-11 19:35     ` gautier...@hotmail.com
2020-12-11 22:40     ` Jeffrey R. Carter
2020-12-11 23:45       ` John Perry
2020-12-11 23:49     ` John Perry
2020-12-12  9:38       ` Maxim Reznik
2020-12-12 20:27   ` Stephen Leake [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox