[metapost] Bug with the binary operator `point ... on ...` from Metafun

Franck Pastor franck.pastor at me.com
Mon Mar 9 18:05:16 CET 2015


> Le 9 mars 2015 à 17:17, Hans Hagen <pragma at wxs.nl> a écrit :
> 
> On 3/9/2015 5:01 PM, Franck Pastor wrote:
>> I’ve just encountered a very puzzling bug with the binary operator `point <len> of <path>` defined in the Metafun format.
>> 
>> In the Metafun manual (http://www.pragma-ade.com/general/manuals/metafun-p.pdf), p. 61, this binary operator is defined as such:
>> 
>> primarydef len of pat =
>>  (arctime len of pat) of pat
>> enddef;
>> 
>> So if I write `point 0 on pat`, it should return the starting point of the path <pat>, right? But n. To the contrary, it returns the end point of <pat>! Stranger yet, if I try `point (arctime 0 of pat) of pat`, it returns the starting point, as expected.
>> 
>> This weird behavior is illustrated by the following program, to be run with the Metafun format of course:
>> 
>> beginfig(1);
>> path line[]; line1 = origin -- 3cm*right; line2 = line1 yshifted -1cm;
>> draw line1; draw line2;
>> pickup pencircle scaled 3bp;
>> draw point 0 of line1; % draw a dot at the start point, as expected
>> draw point 0 on line1; % draws a dot at the end point!!!!!
>> draw point (arctime 0 of line2) of line2; % draws a dot at the starting point…
>> endfig;
>> end.
>> 
>> An idea about what is wrong?
>> 
>> I use MetaPost 1.902 and Metafun version 1.004, from TeX Live 2014.
> 
> change > into >= in mp-tool.*
> 
> \startMPpage
> 
>   primarydef len on pat = % no outer ( ) .. somehow fails
>       (arctime if len>=0 : len else : (arclength(pat)+len) fi of pat) of pat
>   enddef ;
> 
>   path line[] ;
>   line1 = origin -- 3cm*right ;
>   line2 = line1 yshifted -1cm ;
>   drawarrow line1 ;
>   drawarrow line2 ;
>   pickup pencircle scaled 3bp ;
>   draw point 0 of line1 ; % draw a dot at the start point, as expected
>   draw point 0 on line1 withcolor blue ; % draws a dot at the end point!!!!!
>   draw point 2cm on line1 withcolor red ; % draws a dot at the end point!!!!!
>   draw point (arctime 0 of line2) of line2 ; % draws a dot at the starting point…
> 
> \stopMPpage
> 

> 
> -----------------------------------------------------------------
>                                         Hans Hagen | PRAGMA ADE
>             Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>   tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
>                                            | www.pragma-pod.nl
> -----------------------------------------------------------------
> --
> http://tug.org/metapost/


I see. It did not think that the implementation of the `point … on …` operator could have become different from the way it is written in the Metafun manual.  Now I understand from where this weird behavior came, and why. A little oversight with big consequences :-) I should have looked into the mp-tool files first.

Groot bedankt!

Franck Pastor
Athénée royal Victor Horta
Rue de la Réthorique 6
1060 Bruxelles
BELGIQUE
pastorf at arvh.be






More information about the metapost mailing list