Skip to Content.
Sympa Menu

k-user - Re: [K-user] Check "global" cell property and re-write

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Check "global" cell property and re-write


Chronological Thread 
  • From: Traian Florin Șerbănuță <traian.serbanuta AT info.uaic.ro>
  • To: Charles Jacobsen <charlie.jacobsen AT utah.edu>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] Check "global" cell property and re-write
  • Date: Wed, 12 Jun 2013 13:32:53 +0300
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hi Charlie,

Your question is quite interesting...

However, K does not (yet :-) ) support this kind of functionality in the current version.

What one could do would be to write the matching pattern as they wish, and then repeat the fragment in the condition.

In a previous prototype of K we used to allow a where clause, which acted like a macro expansion.  With that, your rule could be expressed as:

rule <agents> A => ? </agents>
  when numThreads(A) <Int 301
  where A:Bag = <stuff to match>

instead of its expansion
rule <agents> <stuff to match> => ? </agents>
  when numThreads(<stuff to match>) <Int 301

which is what you can do in the current version.


best wishes,
Traian



2013/6/10 Charles Jacobsen <charlie.jacobsen AT utah.edu>
Suppose, for example, that a rule re-writes a cell <x> that is a bag containing heavily nested cells (e.g., the <agents> cell in the CHALLENGE language in the overview). Suppose one would like to re-write some cell within <x> under the condition that <x> satisfies a certain property that cannot be expressed as a simple pattern. Is there a nice way to do this without using auxiliary cells to track the property?

For example, suppose a maximum of 300 threads are allowed, globally across all agents, in the CHALLENGE language. One could keep a global thread count, but would it be possible to do something like:

<agents> A:Bag => ? </agents>
where numThreads(A) <Int 301

but how to fill in ? now that we've abstracted the inner structure of <agents>? Is there a way one could refer to the entire cell, but still maintain some of its structure?

This question is more out of curiosity.

Thanks,

Charlie

_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user





Archive powered by MHonArc 2.6.16.

Top of Page