Re: [csswg-drafts] [css-values] String concatentation (#542)

The CSS Working Group just discussed `String Concatenation`, and agreed to the following:

* `RESOLVED: work on astring-coercion-and-concatenation function`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: String Concatenation<br>
&lt;astearns> github: https://github.com/w3c/csswg-drafts/issues/542<br>
&lt;fantasai> leaverou: There's a bunch of string value accepting proeprties in CSS, and can't use variables in there<br>
&lt;fantasai> leaverou: paths<br>
&lt;fantasai> leaverou: Lots of places where concatenation would be useful<br>
&lt;fantasai> leaverou: and don't have a way to do it<br>
&lt;fantasai> leaverou: Didn't recall any objections to the propsoal, just questions about what it's called<br>
&lt;fantasai> leaverou: I don't care, we just need a way to do it<br>
&lt;AmeliaBR> q+<br>
&lt;fantasai> chris: ppl using preprocessors take string concatenation for granted, it's simple there<br>
&lt;fantasai> chris: they're astounded when they find it's not available in raw CSS<br>
&lt;fantasai> leaverou: Primarily useful in URLs, but also useful in other places like paths<br>
&lt;fantasai> TabAtkins: I agree with the need for a function here, prefer concat() but fine with anything else<br>
&lt;chris> q?<br>
&lt;fantasai> leaverou: We've also had suggestions for a function that converts things to strings,<br>
&lt;xfq> ack AmeliaBR<br>
&lt;fantasai> leaverou: text() is generic enough to do both<br>
&lt;fantasai> string() sgtm<br>
&lt;fantasai> AmeliaBR: Problem with that is that for string coercion you often also want number formatting<br>
&lt;fantasai> AmeliaBR: so that might need to be a separate function<br>
&lt;fantasai> AmeliaBR: butwould need to be partof the system if you are going to make useful path dat from numeric variables<br>
&lt;fantasai> AmeliaBR: need to concatenate not just letters but numbers from variables<br>
&lt;fantasai> AmeliaBR: calc expressions<br>
&lt;dbaron> q+ to ask what the inputs to this function can be, and where it can be used<br>
&lt;fantasai> AmeliaBR: etc.<br>
&lt;fantasai> TabAtkins: What are the use cases for coercion? Debugging ovviousl, anything else?<br>
&lt;fantasai> leaverou: ...<br>
&lt;fantasai> Am Big in dataviz<br>
&lt;leaverou> s/.../generated content to display a variable value in the UI/<br>
&lt;leaverou> q+<br>
&lt;fantasai_> AmeliaBR: e.g. bar graphs, want to use value in drawing but also labelling<br>
&lt;fantasai_> AmeliaBR: don't want to duplicate content<br>
&lt;fantasai_> TabAtkins: I really don't want to get into string formatting<br>
&lt;fantasai_> TabAtkins: otherwise do see the value in do see value in displaying 50% on bar chart while 50% also used to size the bar chart<br>
&lt;fantasai_> AmeliaBR: So if we want to leave the generic number formatting issue for later, that's fine<br>
&lt;fantasai_> AmeliaBR: So long as we still have idea that basic concat function can take non-string values and simply print them out<br>
&lt;fantasai_> AmeliaBR: so you can use them for path data<br>
&lt;fantasai_> AmeliaBR: In path data you generally want to preserve maximum precision anyway<br>
&lt;fantasai_> leaverou: example ... interpolation<br>
&lt;fantasai_> leaverou: Don't want to define how concat() interpolates with each other<br>
&lt;xfq> ack db<br>
&lt;Zakim> dbaron, you wanted to ask what the inputs to this function can be, and where it can be used<br>
&lt;fantasai> dbaron: Reading the proposal wasn't clear to me what the inputs of this function is and what the output is in terms of types<br>
&lt;fantasai> dbaron: What CSS value types can be used in here?<br>
&lt;fantasai> TabAtkins: output tpe is tring<br>
&lt;fantasai> TabAtkins: input type is any thing, standard serialization of the token<br>
&lt;fantasai> dbaron: There will be a spec defining standard serialization of a token?<br>
&lt;leaverou> s/example ... interpolation/yes, that simplifies interpolation as well, if types of arguments were not coerced we'd need to define interpolation between two concat() calls<br>
&lt;fantasai> TabAtkins: Need that for variables anyway<br>
&lt;fantasai> TabAtkins: If it doesn't exist yet, some othe rspec is implicitly relying on it and it needs to be defined<br>
&lt;fantasai> astearns: Wrt used, it's anywhere with a string?<br>
&lt;fantasai> fremy: Exception for url?<br>
&lt;fantasai> TabAtkins: No, works in url()<br>
&lt;xfq> ack lea<br>
&lt;fantasai> TabAtkins: url() can take a string<br>
&lt;TabAtkins> s/take a string/take only a literal string, there's another issue for generic &lt;string> input/<br>
&lt;fantasai> astearns: I'm hearing lots of nods on having this thing. Any implementer interest?<br>
&lt;fremy> (to clarify what tab said, url() can take a string but not a &lt;string>)<br>
&lt;fantasai> astearns: From silence sounds like, yes this would be a good thing, no it's not a priority<br>
&lt;fantasai> emilio: Expectation is that you can do like sth(var(--whatev))?<br>
&lt;fantasai> emilio: Then how can you define it to be any token?<br>
&lt;fantasai> TabAtkins: var() is processed at a higher level than any value<br>
&lt;fantasai> fremy: If you want a string, you do text("string")<br>
&lt;TabAtkins> (It's specific as taking a &lt;string> in the syntax, but in Syntax we handle url() in special ways that prevent it from taking string-producing functions.)<br>
&lt;fantasai> emilio: If it takes any token<br>
&lt;fantasai> fremy: If it's not a string, then you convert<br>
&lt;fantasai> TabAtkins: I think Emilio got it<br>
&lt;fantasai> astearns: OK, naming. What do we call the thing?<br>
&lt;fantasai> AmeliaBR: Lea suggested text(), but there's already a text() function in paged content<br>
&lt;fantasai> fantasai: How about string? was in Lea's original proposal<br>
&lt;fantasai> leaverou: sounds fine<br>
&lt;fantasai> chris: sounds fine<br>
&lt;bkardell_> lol<br>
&lt;fantasai> AmeliaBR: Sorry, confused things. It's the string() function that exists, text() does not<br>
&lt;fantasai> AmeliaBR: and already implemented<br>
&lt;chris> I care more that it exists, than what precisely it is called<br>
&lt;xfq> https://drafts.csswg.org/css-gcpm-3/#using-named-strings<br>
&lt;tantek> I for one an all for the cat() function, I bet it would poll well on Twitter 😺<br>
&lt;bkardell_> lol<br>
&lt;fantasai> astearns: Any objections to text()?<br>
&lt;chris> Lets go with text<br>
&lt;fantasai> dydz: Prefer concat(), but ...<br>
&lt;Rossen> combine()<br>
&lt;fantasai> AmeliaBR: Want names that are understandable by non-programmers in CSS<br>
&lt;fantasai> AmeliaBR: Also, we tend not to truncate identifiers in CSS<br>
&lt;chris> concat is not immediately obvious to non programmers either. both cat and concat are abbreviations<br>
&lt;fantasai> TabAtkins: We are not using cat(), tantek!<br>
&lt;tantek> 😿<br>
&lt;fantasai> bkardell_: I don't have a better suggestion, but text() is not very clear to me<br>
&lt;TabAtkins> text(50%)<br>
&lt;Rossen> +1 to bkardell_<br>
&lt;fantasai> bkardell_: There are so many ways that I coudl interpret "text"<br>
&lt;tantek> +1 to bkardell_<br>
&lt;fantasai> flatten() :P<br>
&lt;fantasai> chris: I think it's pretty clear<br>
&lt;fantasai> myles__: We should think about whether concatenation or coercion is more common use case<br>
&lt;TabAtkins> url(text("http://example.com", var(--foo)))<br>
&lt;florian> echo() ?<br>
&lt;tantek> printf()<br>
&lt;florian> printf()<br>
&lt;fantasai> AmeliaBR: text() is clear for coercion, maybe less clear for concatenation<br>
&lt;TabAtkins> No unixisms!<br>
&lt;TabAtkins> y'all weirdos!<br>
&lt;chris> and text(var(--foo)) with one param is clearer than concat(var(--foo))<br>
&lt;Rossen> stringify()<br>
&lt;Rossen> toString()<br>
&lt;TabAtkins> to-string()<br>
&lt;chris> DOTtoString<br>
&lt;dbaron> hopefully everybody has forgotten XPath by now?<br>
&lt;tantek> Time for a Twiter survey!<br>
&lt;fantasai> iank_: Spreadsheets use concatenate and concat<br>
&lt;fantasai> TabAtkins: It's terrible and hard to spell<br>
&lt;fantasai> TabAtkins: These are all great names, except for all the ones that are bad.<br>
&lt;chris> https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/concat<br>
&lt;fantasai> TabAtkins: Let's table this and put together a non-binding Twitter poll<br>
&lt;fantasai> florian: Make sure you include an international audience<br>
&lt;fantasai> bkardell_: That works best if we all promote it so let us know<br>
&lt;fantasai> leaverou: Twitter doesn't have enough space for examples, and based on what examples you use can get different reactions<br>
&lt;fantasai> TabAtkins: I'll put together coercion example and concat example, and you can review them<br>
&lt;chris> https://stackoverflow.com/questions/9493732/difference-between-text-and-string<br>
&lt;fantasai> astearns: Sounds like we'll do this and decide the name later, would be interested in implementer interest<br>
&lt;fantasai> astearns: Any objections?<br>
&lt;fantasai> RESOLVED: work on astring-coercion-and-concatenation function<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/542#issuecomment-467978463 using your GitHub account

Received on Wednesday, 27 February 2019 18:34:59 UTC