Stratego/XT JIRA  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STR-264
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Martin Bravenboer
Reporter: Martin Bravenboer
Votes: 0
Watchers: 0
Operations

Clone this issue
Create sub-task
If you were logged in you would be able to see more operations.
Stratego/XT

collect-all: recurse to current term instead of children of current term

Created: 2005-02-25 21:47   Updated: 2008-03-31 20:39
Component/s: stratego-lib - Stratego Library
Affects Version/s: 0.13
Fix Version/s: 0.16 (Stratego Core Compiler)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
Reported by Ron de Bruijn:

> I don't understand the reason for the semantics of collect-all/3.
>
> This is my definition for collecting all variables (but not those on the
> LHS etc.).
> strategies
> collectAllRHS = collect-all(?Var(_), conc, ignoreFirstArgAssign <+
> ignoreFunctionCall)
>
> rules
> ignoreFirstArgAssign:Assign(_, e) -> e
> ignoreFunctionCall:Call(_, arglist) -> arglist
>
> If I run this on Assign(Var("x"),Var("y")) I would expect [Var("y")],
> but I get []
> The only explanation I can think of is that after Assign(_, e) -> e has
> been applied, it's not matched with ?Var(_). I solved it by putting the
> explanatory Useless around e in ignoreFirstArgAssign. Why would anyone
> want this behaviour? Is this a bug?

Interesting point. I agree that this behaviour is weird and I cannot think of a case where this behaviour might be useful. Weird that this didn't come up earlier.

I think this should be fixed in some way, but the obvious fix might cause problems:

collect-all(s, un, skip) =
    rec x(
       ![<s> | <crush(![],un,x)>]
    <+ skip; crush(![],un,x)
    <+ crush(![],un,x)
    )

If the crush(![],un,x) after the skip would be replaced by an x (that would solve this bug), then this could lead to non-termination if the skip argument is an identity. I'm not sure if that should be allowed.

I've created an issue for this. Any opinions?

For now, you can create you're own collect-all variant if you want to.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order:
There are no comments yet on this issue.