[m-users.] State variables

Sean Charles (emacstheviking) objitsu at gmail.com
Sat Sep 18 07:19:10 AEST 2021


Perfect! I had almost sorted myself out, I found a great example of the usage here in the ODBC code:

 845 odbc.execute(SQLString, !DB) :-
 846     some [!Statement] (
 847         odbc.alloc_statement(!:Statement, !DB),
 848         odbc.execute_statement(SQLString, !Statement, !DB),
 849         odbc.cleanup_statement_check_error(!.Statement, !DB)
 850     ).

And from there I almost had it done but your final comment about the return value was exactly what I was scratching my head about. Great response as always and thanks once again Zoltan.

Sean


> On 17 Sep 2021, at 22:16, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> 
> 
> 2021-09-18 07:04 GMT+10:00 "Sean Charles (emacstheviking)" <objitsu at gmail.com>:
>> I guess what I am asking is, how do I start the process of, creating the state variable in scope,
> 
> Like this:
> 
>  some [!SV]
>  (
>     !:SV = ...,
>     ...
>     ... !.SV
>  )
> 
>> the reference says that they have to be introduced into the head scope
> 
> I will fix that.
> 
> Note that there is another wrinkle in your example. If you want the graphics state
> to be threaded through your code using di,uo argument pairs, then you cannot
> wrap up the initial state in a maybe, because putting a unique value in a term
> destroys its uniqueness. So in your place, instead of a returning yes(G), I would
> return a yes() wrapped around something from which the initial G could be *computed*
> as a unique value.
> 
> Zoltan.



More information about the users mailing list