Arc Forumnew | comments | leaders | submitlogin
1 point by eds 5844 days ago | link | parent

Something like ->foo would be nice. Even if it didn't have that exact syntax, I use 'coerce enough that it would make a (noticeable albeit small) difference in my code. And I think it is more readable than looking at lots of nested type checks.

Are different ssyntaxes be combinable? Could you, for example,

  (if (int?//num? n)
      ; its a number...
      ; not a number...
Do these ssyntaxes currently get optimized away at compile time (i.e. like 'compose does)? Or do they incur a run-time penalty of some sort?


2 points by almkglor 5844 days ago | link

> Are different ssyntaxes be combinable?

With proper ordering of the ssyntaxes in 'def-all-ss, yes.

> Do these ssyntaxes currently get optimized away at compile time (i.e. like 'compose does)? Or do they incur a run-time penalty of some sort?

Not yet. The run time penalty should be as small as a function-composition overhead. The optimization away of 'compose is done by the Scheme-side 'ac, so if optimizations for 'orf and 'andf and similar are desired, munging them in the scheme-side is necessary.

Edit: As an aside, the above ssyntaxes are not yet implemented in the ssyntaxes.arc file. For the most popular ones - postfix ?, as well as 'andf && and 'orf //, you can modify:

    (def-all-ss
      //   (orf ...)
      &&   (andf ...)
      #\:  (compose ...)
      ~    (complement R)
      ~    no
      #\.  (...)
      !    (L 'r)
      ?    [isa _ 'L])
then you can explore away ^^

-----