Output better message for wrong argument of dash-definiton (issue 321400043 by thomasmorley65@gmail.com)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Output better message for wrong argument of dash-definiton (issue 321400043 by thomasmorley65@gmail.com)

Thomas Morley-2
Reviewers: ,

Message:
Please review

Description:
Output better message for wrong argument of dash-definiton

Previously an argument like '(0 1.0 0.5 0.5) passed the
pair?-typecheck, segfaulting later.
Thus a new predicate, list-of-lists? is introduced.

Please review this at https://codereview.appspot.com/321400043/

Affected files (+4, -1 lines):
   M scm/c++.scm
   M scm/define-grob-properties.scm


Index: scm/c++.scm
diff --git a/scm/c++.scm b/scm/c++.scm
index  
a455afdd78a4cf69116dd7809bc2f227cf9b0bd1..57ea44f72c39e5a002b7589d725aaa388d326dae  
100644
--- a/scm/c++.scm
+++ b/scm/c++.scm
@@ -105,6 +105,9 @@
  (define-public (cheap-list? x)
    (or (pair? x) (null? x)))

+(define-public (list-of-lists? x)
+  (and (list? x) (every list? x)))
+
  (define-public (symbol-list-or-symbol? x)
    (if (list? x)
        (every symbol? x)
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index  
0acc741f1cb93ad13ffa151b8fafc745df9037f0..1faab2a21be119e8b96c7c2114bc7398e64f43f4  
100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -210,7 +210,7 @@ increments from this initial value.")
  ;;; d
  ;;;
       (damping ,number? "Amount of beam slope damping.")
-     (dash-definition ,pair? "List of @code{dash-elements} defining the
+     (dash-definition ,list-of-lists? "List of @code{dash-elements}  
defining the
  dash structure.  Each @code{dash-element} has a starting t value,
  an ending t-value, a @code{dash-fraction}, and a @code{dash-period}.")
       (dash-fraction ,number? "Size of the dashes, relative to



_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
dak
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Output better message for wrong argument of dash-definiton (issue 321400043 by thomasmorley65@gmail.com)

dak
On 2017/08/02 20:44:07, thomasmorley651 wrote:
> adds list-of-lists? in lilypond-scheme-predicates

Frankly, I find that sort-of pointless: this just replaces one
insufficient predicate with a slightly less insufficient one.  It's nice
that this triggers an error at the point of call rather than evaluation,
but it seems like proper value-checking at the point of evaluation is
still called for when a generic predicate like list-of-list? is being
used.

https://codereview.appspot.com/321400043/

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Output better message for wrong argument of dash-definiton (issue 321400043 by thomasmorley65@gmail.com)

Thomas Morley-2
In reply to this post by Thomas Morley-2
On 2017/08/02 20:53:46, dak wrote:
> On 2017/08/02 20:44:07, thomasmorley651 wrote:
> > adds list-of-lists? in lilypond-scheme-predicates

> Frankly, I find that sort-of pointless: this just replaces one
insufficient
> predicate with a slightly less insufficient one.  It's nice that this
triggers
> an error at the point of call rather than evaluation, but it seems
like proper
> value-checking at the point of evaluation is still called for when a
generic
> predicate like list-of-list? is being used.

Well, I get your point.
Nevertheless, segfaulting with no other message is worse.
Could you elaborate a bit more verbose how to do it better?

https://codereview.appspot.com/321400043/

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Loading...