About this FAQ

Q: Is there a list of Frequently Asked Questions about Stratego?

A: Until now there wasn't. This page is the place to ask questions and look for answers. If you have a question, add it here.


Q: I get errors when compiling Stratego programs or when running compiled Stratego programs.

A: If you've carefully followed the installation instructions and you are still having problems, please file a bug report. Make sure to specify your configuration (OS, gcc version, Stratego version), include the error message and if posisble try to reduce to problem to a small piece of code.

Q: Does StrategoXT support Microsoft Windows?

A: StrategoXT should more or less work on Microsoft Windows + Cygwin. More or less is however not precise enough, so we are currently investigating whether there are any real problems with Microsoft Windows support. A firm answer is scheduled for StrategoXT 0.9.3. In the near future we will test Microsoft Windows support in the daily build system.

Stratego interpreter

Q: How do I proceed to write Stratego code that's both interpretable and compilable? Is that a goal for the interpreter that this is possible ?

A: Yes, the compiler and the interpreter work on the same language. You can consider the list of commands in a script as the main strategy of a specification. There should be no difference in semantics between the compiler and the interpreter. Except for the fact that there is a definition before use regime in the script itself (not in modules imported in the script). That is, that is defined in the script can only be used (in a command) after it has been declared.


Q: How do I get more debugging info ? The tools are awfully quiet unless I chock my code full of debug invocations. Can I somehow set up an 'exception handler' that shows the traversed stack and line number (or something similar) when a rewriting fails miserably?

A: See debugging techniques

Stratego language

Q: What is the difference between a strategy and a rule?

A: See rules versus strategies

Q: In what ways can variables be bound?

A: A variable is only bound during matching. That is, while applying a pattern match ?t to the subject term. All constructs that bind variables, ultimately use this pattern matching construct to bind variables.

Dynamic rules

Q: I get unexpected behaviour with two different dynamic rules with the same label.

A: If you are not using StrategoXT 0.9 or later please upgrade. For more information see dynamic rule semantics.

Stratego standard libary

Q: collect removes duplicates, is there collect-with-duplicates?

A: Yes, there is. The collect strategy is an alias of collect-om. collect-om has a variant that takes a strategy argument that is used to combine intermediate results. If you pass conc instead of union, then duplicates will not be removed.

Q: Is it possible to redirect the stderr of process to a file in Stratego?

A: Yes, this works exactly the same a redirection in C. Example:

    module example
    imports posix-file char-io


      main =
          <open> "error.txt" => fd
        ; <dup2> (fd, <STDERR_FILENO>)
        ; <debug> "bla bla bla 1"
        ; <fputs> ("bla bla bla 2", <stderr-stream>)
        ; <close> fd
See 'man dup2' for more information.

If you want to execute a new process, the following strategy is useful:

   * Execute program in a new process with list of string args, 
   * with the specified exec strategy.
   * Optionally you can define file descriptors to use for stdin, stdout,
   * stderr.
   * @param  opt-fdin   Option(FileDescr)
   * @param  opt-fdout  Option(FileDescr)
   * @param  opt-fderr  Option(FileDescr)
   * @type  (String, List(String)) -> ()
  call(|opt-fdin, opt-fdout, opt-fderr) =
      ?(prog, args)
      ; fork-and-wait(
          <option(<dup2> (<id>, <STDIN_FILENO> ))> opt-fdin
        ; <option(<dup2> (<id>, <STDOUT_FILENO>))> opt-fdout
        ; <option(<dup2> (<id>, <STDERR_FILENO>))> opt-fderr
        ; <execvp> (prog, args)
        ; <exit> 1
      ; !()
This strategy might become part of the SSL in the future.

Revision: r1.15 - 10 Nov 2004 - 16:02 - MartinBravenboer
Stratego > FrequentlyAskedQuestions
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback