Re: [Groff] pic: nasty little trap in function!

2015-03-02 Thread Werner LEMBERG
> Tadziu Hoffmann wrote: > a better definition would have been: > define d2r {($1)*pi/180} > > Yes. Macros are expanded by simple textual substitution. They are > totally disconnected from the language syntax. It is a cardinal > rule that parameters which you see as subexpressions in formulas

Re: [Groff] pic: nasty little trap in function!

2015-03-02 Thread Doug McIlroy
Tadziu Hoffmann wrote: a better definition would have been: define d2r {($1)*pi/180} Yes. Macros are expanded by simple textual substitution. They are totally disconnected from the language syntax. It is a cardinal rule that parameters which you see as subexpressions in formulas be parenthesized

Re: [Groff] pic: nasty little trap in function!

2015-03-02 Thread Tadziu Hoffmann
> define d2r {$1*pi/180} > > t = d2r(15.0+0.5*i) "define" being a (text-replacement) macro facility, this can be understood as follows: t = d2r(15.0+0.5*i) = 15.0+0.5*i*pi/180 so a better definition would have been: define d2r {($1)*pi/180} I think similar pitfalls exist with cpp macr

[Groff] pic: nasty little trap in function!

2015-03-02 Thread Ted Harding
Greetings All! I was recently wanting to draw someline segments along radii of a circle, at series of angles. Since I wanted to "think in degrees", while the sin() and cos() functions work in radians, I defined a function in pic according to: .PS pi = 4*atan2(1,1) define d2r {$1*pi/180} .PE Then