You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "Mike Beckerle (Jira)" <ji...@apache.org> on 2021/08/31 15:37:00 UTC

[jira] [Issue Comment Deleted] (DAFFODIL-2542) Change diagnostics to use string interpolation

     [ https://issues.apache.org/jira/browse/DAFFODIL-2542?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Beckerle updated DAFFODIL-2542:
------------------------------------
    Comment: was deleted

(was: See my comments on DAFFODIL-2542 for more about i18n and the requirements to do it right.

The f-interpolator type checks against the % characters in the string. So if you say f"$height%n" then you get a compile-time type error if height isn't a number. 

Using s-interpolator you would get no such type check because the string does not express the intent that a number is expected. 

Maybe this is a minor thing, but given the importance of number vs. non-number for i18n, I think it is good to have the numbers explicit in the strings. 

I concur that one could change f"..."  to i18n"..." in the future. )

> Change diagnostics to use string interpolation
> ----------------------------------------------
>
>                 Key: DAFFODIL-2542
>                 URL: https://issues.apache.org/jira/browse/DAFFODIL-2542
>             Project: Daffodil
>          Issue Type: Improvement
>          Components: Diagnostics
>            Reporter: Steve Lawrence
>            Priority: Minor
>              Labels: beginner
>
> Our various diagnostics use a format string plus varargs to build a message. For example
> {code:scala}
> this.SDE("Some error message: %s", someArgument)
> {code}
> One downside of this approach is that there is no compile time validation of the format string and arguments. So if the the format strings and args don't match, it can lead to unexpected error messages or runtime errors.
> An alternative approach is to use string interpolation:
> {code:scala}
> this.SDE(s"Some error message: ${someArgument}")
> {code}
> This completely avoids the possibility of format string/var args missmatch.
> We should go through our diagnostic messages and switch to using string interpolation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)