title: User defined functions with LessCSS?
body: <p>I have just recently gotten into LessCSS and I am running into what I feel is major limitation and I was wondering if there was a way to do this?? I want to say I read somewhere that Sass allows for user defined functions but will LessCSS do the same?</p>
  
  <p>What I'm wanting to do:</p>
  
  <pre><code>@fs: 16;
  
  // either return the value
  .s(@t,@s,@u) {
      // return @t/@s*@u;
  }
  #elem {
      margin-top: .s(30,@fs,1em);
      width: .s(900,@fs,1em);
      .child {
          width: .s(100,900,100%);
      }
  }
  
  // or have a property argument
  .s(@t,@s,@u,@p) {
      @{p}: @t/@s*@u;
  }
  #elem {
      .s(30,@fs,1em,margin-top);
      .s(900,@fs,1em,width);
      .child {
          .s(100,900,100%,width);
      }
  }
  </code></pre>
  
  <p>The only way I can figure it out, but it is very limited because I have to have multiple mixins:</p>
  
  <pre><code>.s(@t,@s,@u,@p) when (@p = margin-top) { margin-top: @t/@s*@u; }
  // margin[-top|-right|-bottom|-left]
  // padding[-top|-right|-bottom|-left]
  .s(@t,@s,@u,@p) when (@p = width) { width: @t/@s*@u; }
  .s(@t,@s,@u,@p) when (@p = height) { height: @t/@s*@u; }
  </code></pre>
  
  <p>I know I can always modify the less.js file to add a spacing function like the built-in <code>round()</code> or <code>ceil()</code> function. But, that kills the option of compiling the .less files for production using LessPHP, Crunch, SimpLess.</p>