Giter Club home page Giter Club logo

Comments (4)

leafac avatar leafac commented on June 13, 2024

Thank you for the kind words about css-expr.

The css-expr form serves not only to generate stylesheets, but also to generate fragments, for example, the main-width in this example. It would be impractical to check whether an arbitrary value can be an arbitrary css-expr fragment.

It’s possible, however, to check whether an arbitrary value is a complete stylesheet (something that could be passed to css-expr->css and wouldn’t raise an error):

(define (css-expr? expr)
  (with-handlers ([exn:fail:syntax? (λ (e) #f)])
    (parse expr)
    #t))

> (css-expr? (css-expr [body #:background-color black]))
#t
> (css-expr? (css-expr a-css-expr-fragment))
#f

Would this be useful to you?

from css-expr.

jessealama avatar jessealama commented on June 13, 2024

Hmm...for what I have in mind, I think that might be a bit too weak. But perhaps I'm misunderstanding something. Is it true that every S-expression composed of symbols (and which is a list) could have been generated by css-expr? Playing around, I find that I can generate pretty much whatever I want:

(css-expr foo) ; ==> '(foo)
(css-expr "foo") ; ==> '("foo")
(css-expr #"hi") ; ==> '(#"hi")
(css-expr hi there (you now (horton)) ; ==> '(hi there (you now (horton)))

The byte string example there is a bit surprising, but overall, these examples suggest to me that essentially any S-expression could be generated using css-expr. And that's reinforced when I read your solution using parse. Do I understand things correctly?

from css-expr.

leafac avatar leafac commented on June 13, 2024

You understand correctly, the css-expr form can generate any S-expression because it’s just another name for quasiquote. The css-expr form is intended to be flexible and capable of generating any fragment of a CSS-expression—it’s just a way for the programmer to communicate “this S-expression is a CSS-expression (or fragment thereof).”

from css-expr.

jessealama avatar jessealama commented on June 13, 2024

Thanks for clarifying -- I now see that my request is based on a misunderstanding of what css-expr does.

from css-expr.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.