'Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0

In these functions I compile rem to px and em to px:

$base: 16 !default;

@function scut-strip-unit($num) {
  @return $num / ($num * 0 + 1);
}

@function rem($pixels) {
  @return scut-strip-unit($pixels) / $base * 1rem;
}

@function em($pixels, $context: $base) {
  @return #{$pixels / $context}em;
}

But with Sass v1.49, we are facing this error:

Error
Deprecation Warning: Using / for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0.    

Recommendation: math.div(scut-strip-unit($pixels), $base) or calc(scut-strip-unit($pixels) / $base)    

More info and automated migrator: https://sass-lang.com/d/slash-div 
   
  ╷
8 │ @return scut-strip-unit($pixels) / $base * 1rem;


Solution 1:[1]

To avoid using sass:math, you may just use

calc(scut-strip-unit($pixels) / $base)

Solution 2:[2]

If you need a bunch of constants the best approach is usually to have a bunch of constants: you are going to need to wire in the names of things anyway: there's nothing to be gained by (f '<name>) or (m <name>) instead of just <name> unless you want <name> to refer to something else as well. If you want those constants all defined in one place then that's easy. I assume (based on defconst) you are writing elisp, and if so a macro like this will serve:

(defmacro define-constants (&rest forms)
  `(progn
     ,@(mapcar (lambda (form)
                 `(defconst ,@form))
               forms)))

And now

(define-constants
  (foo 1)
  (bar 2)
  ...)

(Disclaimer: I have not kept up with the changes in elisp in the last 20 years or more: the above works on Emacs 27.2.)

If you're using Common Lisp or some other Lisp there are often better approaches.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ulfius
Solution 2 ignis volens