开发者

Does SASS have gotchas like the C preprocessor?

开发者 https://www.devze.com 2023-03-03 17:16 出处:网络
SASS, on first impression, seems to be a C-preprocessor-style tool for various code smells (like lots of copying and pasting) that come with production CSS.

SASS, on first impression, seems to be a C-preprocessor-style tool for various code smells (like lots of copying and pasting) that come with production CSS.

I was explaining SASS as being like C's preprocessor, and that raised a question. The C preprocessor has some very good uses: defining constants, perhaps, or including header files. But there are also certain things that are "considered harmful", in particular using the preprocessor as a tool to do the work of a function whilst sidestepping the overhead of using a function. The preprocessor has an important place, but if you have a c开发者_开发问答hoice between implementing something via preprocessor macros and implementing it as a function, chances are you should be using a function, not the preprocessor.

Are there any gotchas like that for using SASS?


Since SASS (and indeed any such tool) provides functionality that is orthogonal to that of basic CSS I think the dangers are much reduced in comparison to the C pre-processor.

For example a C macro can be made to look exactly like a C function. You can't tell the difference between them in the source code but their semantics are very different. In SASS this is not the case because variables, mixins etc. have special syntax that is clearly not CSS.

0

精彩评论

暂无评论...
验证码 换一张
取 消