Re: [Taoscript-lang] rot13.tao reveals Tao (or documentation?) shortcoming :-<
Status: Beta
Brought to you by:
phoolimin
|
From: Limin Fu <fu....@gm...> - 2005-06-06 09:09:18
|
This is a re-sended message which was not previously sent to this mailing=
=20
list by mistake :)
Hi!
The feature in your first question is not implemented, I will do it.=20
The command line arguments are stored in an array named COMARG, which has t=
o=20
be accessed by the current namespace"this", namely, this.COMARG or=20
this::COMARG.=20
This command argument accessing was not elegantly support, probably it will=
=20
be changed. And probably in the following ways, "this" will be given the=20
same meaning as in C++ to mean the current object, the current namespace=20
will be accessed with "here"; A special namespace will be used to store=20
command line arguments, environment variables etc... For convenience,=20
accessing classes and routines in a namespace will not require expilicit=20
specifying its namespace, they will be searched automatically from current=
=20
namespace and other namespace accessable from the current namespace.
"rot[rot.#] =3D x" fails on purpose ( I should have let it give a warning),=
=20
since "rot" is an array. If "rot" and "x" are strings, "rot[rot.#] =3D x" w=
ill=20
insert "x" to the end of "rot". This kind of operation is not supported for=
=20
array because if "x" is also an array, "rot[rot.#] =3D x" will be ambiguous=
,=20
since "x" can be inserted into "rot" as a whole or element by element.
I understand your motivation for having such capabilities. Your suggestions=
=20
are very good, by myself alone I can't have prevision for all possible=20
important features for the language. Thank you for the suggestions :-)
Limin FU
On 6/1/05, Josef 'Jupp' SCHUGT <ju...@gm...> wrote:
>=20
> Hi!
>=20
> At the end of this message I added rot13 written in Tao. If you do not
> know it: rot13 is a Cesar encoding; an implementation of rot13 using
> standard Unix tools is
>=20
> tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
>=20
> The Tao script works flawlessly - for a single line. I am an old Linux
> hand so I have two questions not answered by the documentation.
>=20
> - How to make the program iterate over all input provided via
> standard input unless EOF is encountered?=20
>=20
> - How to access command line arguments?
>=20
> The reason is obvious: Without these two means it is impossible to
> write Unix style tools in Tao that are capable of both processing
> input streams and files. Bad.=20
>=20
> I am pretty sure most people who know why this is bad but perhaps not
> all do. I therefore describe my motivation for having such
> capabilities.
>=20
> A typical problem when dealing with data is this:
>=20
> You have to implement operation F on data of the same type that is
> provided by different sources and need to be provided to other people.
> While the data are in principle always of the same type you have to
> deal with input formats i1, i2, i3, ..., iN and output formats o1, o2,=20
> o3, ... oM. If you implement all functionality in one program you end
> up with always modifying the program whenever a new source is added.
> Bad. A data processing program should only be modified if the
> information it processes, the information it extracts or the way in=20
> which the information input is transformed into the information output
> (i.e. the algorithm) changes but it should *never* need to be modified
> if the representation of the data is changed without actually
> modifying the informational content. It's simply the "never change a=20
> winning team" (aka "never touch a running system") issue. It is much
> better to have filters that transform i1, i2, i3, ..., iN into a
> generic input format I, then process this input with a program that=20
> produces some generic output format O and have this output then
> transformed by other filters into any of o1, o2, o3, ..., oM.
>=20
> A great example of tools that follow this style is netpbm that comes
> with filters that transform an awful lot of graphics formats into a=20
> PBM (a trivial graphics format) and others that transform PBM into an
> awful lot of output formats (there are also programs that can do
> quantization and the like so F is known to exist as well :-). If
> netpbm does not support your format simply write two tools: One that=20
> transforms the format to PBM and one for the opposite direction. Now
> netpbm supports your format.
>=20
> Enough motivation, here's code (note that it does not work on EBCDIC
> systems!):
>=20
>=20
>=20
> a =3D read();=20
> orig =3D unpack(a);
> rot =3D { };
> foreach(orig:x) {
> if (x >=3D unpack("a")[0] && x <=3D unpack("z")[0]) {
> x =3D (x + 13 - unpack("a")[0]) % 26 + unpack("a")[0];=20
> } else if (x >=3D unpack("A")[0] && x <=3D unpack("Z")[0]) {
> x =3D (x + 13 - unpack("A")[0]) % 26 + unpack("A")[0];
> }
> rot.insert(x);
> }
> print (pack(rot), "\n");=20
>=20
>=20
>=20
> Before I forget to ask: Does "rot[rot.#] =3D x" fail on purpose instead
> of meaning the same as "rot.insert(x)"?
>=20
> Josef 'Jupp' SCHUGT
> --
> "NO" to the European constitution means "YES" to democracy, not "NO" to=
=20
> Europe - presently Europe as a whole is governed by a central committee
> while the parliament only has very limited power. Thank you, France.
>=20
>=20
> -------------------------------------------------------
> This SF.Net <http://SF.Net> email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=3Doffad-ysdn-ostg-q22=
005
> _______________________________________________
> Taoscript-lang mailing list
> Tao...@li...
> https://lists.sourceforge.net/lists/listinfo/taoscript-lang
>
|