title: Does Prolog have an alias "operator" like Haskell?
body: <p>In Haskell, there is a language feature called "as"-operator (sometimes known as alias). The idea is the following: given you have a function that for instance takes as input a list and wants to return all tails, you can implement this as:</p>
  
  <pre><code>tails a@(_:xs) = a : tails xs
  tails [] = [[]]
  </code></pre>
  
  <p>The <code>@</code> ensures that you have a reference to both the entire argument as well as a reference to some parts of the structure of the parameter. This is intelligent performance-wise (it is more a performance hack, because reconstructing an array <code>(x:xs)</code>) in the body of the first line, will - if not optimized by the compiler - result in allocating a new object, modifying fields, etc. See <a href="https://stackoverflow.com/q/1153465/67579">here</a> for more information.</p>
  
  <p>I was wondering if Prolog has something equivalent: for instance if you want to implement tails in Prolog, it can be done the following way:</p>
  
  <pre><code>tails([H|T],[[H|T]|TA]) :-
      tails(T,TA).
  tails([],[[]]).
  </code></pre>
  
  <p>But it could be more efficient if there was an "as"-operator like:</p>
  
  <pre><code>tails(L@[_|T],[L|TA]) :-  %This does not compile
      tails(T,TA).
  tails([],[[]]).
  </code></pre>
  
  <p>Is there any such construct, or a language extension?</p>