groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] question regarding PIC and variable scoping


From: Werner LEMBERG
Subject: Re: [Groff] question regarding PIC and variable scoping
Date: Sun, 23 Jun 2002 23:48:21 +0200 (CEST)

From: karan bhatia <address@hidden>
Subject: Re: [Groff] question regarding PIC and variable scoping 
Date: Sun, 13 Feb 2000 12:02:10 -0800


[About accessing a GNU pic variable in a block from outside]

> >"But according to the documentation, variable scoping works like
> >object scoping" -- according to what documentation?
> 
> I'm interpreting the documentation that you yourself quote:
> 
> >The nearest I can find anywhere is the following quote from Eric
> >Raymond's "Making Pictures with GNU Pic" where (Section 10.2) it
> >says:
> >
> >  "Blocks are also a variable-scoping mechanism, like a groff(1)
> >   environment. All variable assignments done inside a block are
> >   undone at the end of it. To get at values within a block, write
> >   a [sic] name of the block followed by a dot, followed by the
> >   variable or label you want. For example, we could refer to the
> >   center of the box in the above composite as last [].Caption or
> >   A.Caption."
> 
> Doesn't this (and the example of last [].Caption) imply that i can
> get do the same for variables defined within the last []?  "followed
> by the _variable_ or label you want".

This info is not correct.  I've fixed pic.ms.

> >None of this contradicts what I've said above except for the words
> >"variable or". There is no other reference in Raymond's document to
> >accessing internal variables of a block; and indeed the statement
> >that a variable assignment is undone at the end of a block would
> >imply that it is inaccessible. The example he gives is of course a
> >label ("Caption").
> 
> I think we agree that the above reference implies that i can do
> something like last [].variable.  This is exactly the documentation
> i was refering to.  So either the documentation should clarify this
> important distinction between variables and labels (and take out
> "variable or") or perhaps there is a way to add that functionality?

This functionality is already available.  I've added the following to
pic.ms:

  Variables in a block can't be directly accessed from outside; they
  must be converted into a position:

    A: [
         xy = 5;
         Xy: (xy,0);
       ]
    print A.Xy.x


      Werner

reply via email to

[Prev in Thread] Current Thread [Next in Thread]