Four experiments [was Re: [Aleph] feature request :-))]

Giuseppe Bilotta gip.bilotta at iol.it
Mon Jul 26 13:31:27 CEST 2004


Saturday, July 3, 2004 Idris Samawi Hamid wrote:

> Experiment four uses three ocplist-segments; it fails, except that
> the Arabic-script numeral `4' is output.
> But simple numerals do not depend on
> the ocp transformations if they are mapped correctly in the font.

> Question 1: why does experiment 3 _appear_ to work and experiment
> 4 fail? Clearly there must be something special about the third
> case that does not get generalized to the fourth;

> Question 2: what modifications are necessary to make experiments
> 1, 2, and 4 work?

> I eagerly await your thoughts and suggestions

> Best Idris

> ==============ocplist.tex==========================

> % greek ocps
> \ocp\GrTexUni=grpo2uni \ocp\GrUniToFont=uni2greek

> %arabic ocps
> \ocp\ArabUni=7arb2uni
> \ocp\UniCUni=uni2cuni
> \ocp\CUniArab=cuni2oar

> % abstractions for greek
> \def\GreekTranscription{\addbeforeocplist 1 \GrTexUni}
> \def\GreekFont{\addbeforeocplist 1 \GrUniToFont}
> \def\GreekFull{%
>                 \addbeforeocplist 1 \GrTexUni
>                 \addbeforeocplist 1 \GrUniToFont
>                 }

> % default
> \ocplist\GreekOcp=
>                 \addbeforeocplist 1 \GrTexUni
>                 \addbeforeocplist 1 \GrUniToFont
>                 \nullocplist

> % abstraction xperiment 1 % expands the `1'
> \expandafter\ocplist\expandafter\MyGreekOcpOne\expandafter=
> \GreekTranscription
> \GreekFont
> \nullocplist

The above won't work because it expands the space after the =
sign, and not the macros. You need many more \expandafters, too,
because you have to expand both macros.

> % abstraction xperiment 2
> \expandafter\ocplist\expandafter\MyGreekOcpTwo\expandafter=
> \GreekFull
> \nullocplist

To fix this, you only need to put e.g. a comment sing after the
= sign, so that the macros (and not the space) gets expanded by
the \expandafter.

> % abstraction xperiment 3

> \ocplist\GreekOcpSegmentOne=
>                 \addbeforeocplist 1 \GrTexUni
>                 \nullocplist

> \ocplist\GreekOcpSegmentTwo=
>                 \addbeforeocplist 1 \GrTexUni
>                 \nullocplist

First of all, there is a bug here ^^ it should be
\GrUniToFont. If you do this, x3 won't work.

> \font\greek=omlgc at 12pt
> \greek

> %default
> \pushocplist\GreekOcp

> a b c d

> % xperiment 1
> \clearocplists
> \pushocplist\MyGreekOcpOne

> 1 a b c d

> % xperiment 2
> \clearocplists
> \pushocplist\MyGreekOcpTwo

> 2 a b c d

> % xperiment 3
> \clearocplists
> \pushocplist\GreekOcpSegmentOne
> \pushocplist\GreekOcpSegmentTwo

> 3 a b c d

This won't work with the correct segment two. It does work if
you swap the two segments, though.

> % abstraction xperiment for arabic

> % default
> \ocplist\ArabicOCP=
> \addbeforeocplist 1 \ArabUni
> \addbeforeocplist 1 \UniCUni
> \addbeforeocplist 1 \CUniArab
> \nullocplist

> % abstraction xperiment 4
> \ocplist\ArabicOcpSegmentOne=
>                 \addbeforeocplist 1 \ArabUni
>                 \nullocplist
> \ocplist\ArabicOcpSegmentTwo=
>                 \addbeforeocplist 1 \UniCUni
>                 \nullocplist
> \ocplist\ArabicOcpSegmentThree=
>                 \addbeforeocplist 1 \CUniArab
>                 \nullocplist
> \font\arabic=omarab at 12pt
> \arabic
> \textdir TRT\pardir TRT

> % default

> \clearocplists
> \pushocplist\ArabicOCP

> Aal-Hamdu Aal-Hamdu Aal-Hamdu

> \blank[big]

(This should be \bigskip :))

> % xperiment 4
> \clearocplists
> \pushocplist\ArabicOcpSegmentOne
> \pushocplist\ArabicOcpSegmentTwo
> \pushocplist\ArabicOcpSegmentThree

> 4 Aal-Hamdu Aal-Hamdu Aal-Hamdu

Again, I thought that the problem would be that the order of
the segments should be Three-Two-One (since they are "pushed").
But this is absolutely *untrue*.

The problem, and the *proper* way to do it, is to set up
different priorities for the various OCPs! The magic number
after the \add<...>ocplist *should* be different. If you give
priority 1 to the first, priority 2 to the second and priority
3 to the last it *will* work, *regardless of the order in which
you push the ocplists!

Working example:

===ocp-work===
\ocptracelevel=1

% greek ocps
\ocp\GrTexUni=grpo2uni \ocp\GrUniToFont=uni2greek

%arabic ocps
\ocp\ArabUni=7arb2uni
\ocp\UniCUni=uni2cuni
\ocp\CUniArab=cuni2oar

% abstractions for greek
\def\GreekTranscription{\addbeforeocplist 1 \GrTexUni}
\def\GreekFont{\addbeforeocplist 2 \GrUniToFont}
\def\GreekFull{%
                \addbeforeocplist 1 \GrTexUni
                \addbeforeocplist 2 \GrUniToFont
                }

% default
\ocplist\GreekOcp=
                \addbeforeocplist 1 \GrTexUni
                \addbeforeocplist 2 \GrUniToFont
                \nullocplist

% abstraction xperiment 1 % expands the `1'
\expandafter\expandafter\expandafter\ocplist%
\expandafter\expandafter\expandafter\MyGreekOcpOne%
\expandafter\expandafter\expandafter=%
\expandafter\GreekTranscription%
\GreekFont
\nullocplist

% abstraction xperiment 2
\expandafter\ocplist\expandafter\MyGreekOcpTwo\expandafter=%
\GreekFull
\nullocplist

% abstraction xperiment 3

\ocplist\GreekOcpSegmentOne=
                \addbeforeocplist 1 \GrTexUni
                \nullocplist

\ocplist\GreekOcpSegmentTwo=
                \addbeforeocplist 2 \GrUniToFont
                \nullocplist

\font\greek=omlgc at 12pt
\greek

%default
\pushocplist\GreekOcp

a b c d

% xperiment 1
\clearocplists
\pushocplist\MyGreekOcpOne

1 a b c d

% xperiment 2
\clearocplists
\pushocplist\MyGreekOcpTwo

2 a b c d

% xperiment 3
\clearocplists
\pushocplist\GreekOcpSegmentOne
\pushocplist\GreekOcpSegmentTwo

3 a b c d

% abstraction xperiment for arabic

% default
\ocplist\ArabicOCP=
\addbeforeocplist 1 \ArabUni
\addbeforeocplist 2 \UniCUni
\addbeforeocplist 3 \CUniArab
\nullocplist

% abstraction xperiment 4
\ocplist\ArabicOcpSegmentOne=
                \addbeforeocplist 1 \ArabUni
                \nullocplist
\ocplist\ArabicOcpSegmentTwo=
                \addbeforeocplist 2 \UniCUni
                \nullocplist
\ocplist\ArabicOcpSegmentThree=
                \addbeforeocplist 3 \CUniArab
                \nullocplist
\font\arabic=omarab at 12pt
\arabic
\textdir TRT\pardir TRT

% default

\clearocplists
\pushocplist\ArabicOCP

Aal-Hamdu Aal-Hamdu Aal-Hamdu

\bigskip

% xperiment 4
\clearocplists
\pushocplist\ArabicOcpSegmentOne
\pushocplist\ArabicOcpSegmentTwo
\pushocplist\ArabicOcpSegmentThree

4 Aal-Hamdu Aal-Hamdu Aal-Hamdu

\bye
====

Whaddyathinkof this?





More information about the Aleph mailing list