Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #2937

Re: Getting Rid Of PostScript

From Carlos <angus@quovadis.com.ar>
Newsgroups comp.lang.postscript
Subject Re: Getting Rid Of PostScript
Date 2016-11-16 00:17 +0100
Organization A noiseless patient Spider
Message-ID <20161116001758.670c83db@samara.DOMA> (permalink)
References (13 earlier) <66538ba6-282f-4b3d-b8ba-94b93903385f@googlegroups.com> <nunq2l$cib$1@dont-email.me> <41c5fbb5-a268-4cc1-8522-73f92980ce69@googlegroups.com> <20161025210647.55ecd219@samara.DOMA> <8fc71ab3-e706-4f17-a7d6-c1d685577bf4@googlegroups.com>

Show all headers | View raw


[Lawrence D’Oliveiro <lawrencedo99@gmail.com>, 2016-11-14 15:15]
> On Wednesday, October 26, 2016 at 8:07:32 AM UTC+13, Carlos wrote:
> 
> > Operator overloading is a controversial issue.  
> 
> No it isn’t. Even common-or-garden languages like C or Java have
> operator overloading.

Well, yes, even PostScript has it.

> Or did you mean *custom* operator overloads? It may be
> “controversial” the way C++ does it (complicated and clunky). But
> Python handles it in a very simple way.

That's what I meant. I think in a language like PostScript it's better
not to do it, for two main reasons: first (already mentioned), there is
no mathematical notation in PostScript; and second, operators provide
almost all of the code legibility, so the less ambiguous their names,
the better.

But what's great about PostScript is its flexibility. Almost any
language feature is just a library away. If you like operator
overloading, you can have it in PostScript!

Here's an example with a not very sophisticated library (~250 lines).
It's the same vector library stub as last time, but now overloading the
mul operator.

   /vectortype /packedarraytype {
       dup length 2 eq exch { /numbertype isa and } forall
   } deftype

   /Vector { 2 packedarray } bind def
   /x      { 0 get         } bind def
   /y      { 1 get         } bind def
   /xy     { aload pop     } bind def

   /Vop    { 3 1 roll
             xy 3 -1 roll xy
             3 -1 roll 4 index exec
             3 1 roll exch 3 index exec
             exch Vector
             exch pop      } bind def

   /Vmul   { { mul } Vop   } bind def

   /mul [/vectortype /vectortype] { Vmul } defmethod
   
   /mul [/vectortype /numbertype] {
       exch 2 copy x mul
       3 1 roll    y mul  Vector
   } defmethod


   GS>1.5 2 Vector   dup ==   dup type ==   dup dup mul ==   5 mul ==
   [1.5 2]
   vectortype
   [2.25 4]
   [7.5 10]

> > Just the necessary to translate to PostScript the snippets you are
> > posting.  
> 
> The Python code I included in that posting was not “snippets”, it was
> the complete program.

In _that_ posting there were just snippets. In the referred one, there
was some code interspersed with commentary. Are you saying the code
without the commentary make up a complete, working program? In that
case, I shall try to translate it to PostScript. Can I see what the
output is?

> > What? You wrote more lines. Or wasn't the code for Vector and
> > Rectangle classes written by you? I mean, line for line, PostScript
> > wins hands down. Compare:
> > 
> >     def __sub__(v1, v2) :
> >         "difference between two Vectors."
> >         return \
> >             (
> >                 lambda : NotImplemented,
> >                 lambda : type(v1)(v1.x - v2.x, v1.y - v2.y)
> >             )[isinstance(v2, Vector)]()
> >     #end __sub__
> > 
> > with
> > 
> >    /Vsub   { { sub } Vop   } bind def  % vector difference  
> 
> Fine. If you want to include all that code, then by all means provide
> PostScript equivalents for all 6826 lines (current count) of my Cairo
> binding <https://github.com/ldo/qahirah>. Then we can compare.

Actually, it was you who wanted to include my library code in the line
count, while excluding yours. We can count it or not, it's the same to
me. In any case, I'll only write the code needed for the task at hand;
if you want to include library code in the count, I don't expect you to
count your code not involved in the task.

> How many lines of PostScript would that take? I predict you will not
> be able to do it all, no matter how many lines you write.

That's an easy prediction; PostScript doesn't have facilities to load
or access DLLs. But that's not what this is about, is it? This is about
the *languages*, no the libraries.
-- 

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-05 18:24 -0700
  Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-06 14:50 -0700
  Re: Getting Rid Of PostScript jdaw1 <jdawiseman@gmail.com> - 2016-10-06 15:45 -0700
    Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-06 17:44 -0700
    Re: Getting Rid Of PostScript Mark Carroll <mtbc@bcs.org> - 2016-10-07 08:47 +0100
      Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-07 15:08 -0700
        Re: Getting Rid Of PostScript luser droog <luser.droog@gmail.com> - 2016-10-07 18:47 -0700
        Re: Getting Rid Of PostScript Mark Carroll <mtbc@bcs.org> - 2016-10-08 12:34 +0100
  Re: Getting Rid Of PostScript luser droog <luser.droog@gmail.com> - 2016-10-07 18:39 -0700
    Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-07 19:07 -0700
      Re: Getting Rid Of PostScript luser droog <luser.droog@gmail.com> - 2016-10-12 15:32 -0700
        Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-12 17:06 -0700
        Re: Getting Rid Of PostScript rodd@panix.com (Rod Dorman) - 2016-10-13 19:07 +0000
          Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-13 15:02 -0700
            Re: Getting Rid Of PostScript rodd@panix.com (Rod Dorman) - 2016-10-14 20:13 +0000
              Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-14 14:39 -0700
              Re: Getting Rid Of PostScript Martin Leese <please@see.Web.for.e-mail.INVALID> - 2016-10-16 10:40 -0600
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-17 18:06 -0700
                Re: Getting Rid Of PostScript Alan <alan.isaac@gmail.com> - 2016-10-17 18:44 -0700
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-17 22:43 -0700
                Re: Getting Rid Of PostScript Martin Leese <please@see.Web.for.e-mail.INVALID> - 2016-10-18 10:13 -0600
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-18 15:28 -0700
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-18 15:35 -0700
                Re: Getting Rid Of PostScript Ross Presser <rpresser@gmail.com> - 2016-10-18 23:05 -0700
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-10-19 19:23 +0200
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-19 17:17 -0700
                Re: Getting Rid Of PostScript Ross Presser <rpresser@gmail.com> - 2016-10-21 09:18 -0700
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-21 18:10 -0700
                Re: Getting Rid Of PostScript Ross Presser <rpresser@gmail.com> - 2016-10-21 09:14 -0700
                Re: Getting Rid Of PostScript Markus Triska <triska@metalevel.at> - 2016-10-19 20:55 +0200
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-19 17:57 -0700
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-24 16:54 -0700
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-10-25 16:26 +0200
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-25 10:32 -0700
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-10-25 21:06 +0200
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-11-14 15:15 -0800
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-11-16 00:17 +0100
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-11-21 18:37 +0100
                Re: Getting Rid Of PostScript Carlos <angus@quovadis.com.ar> - 2016-11-21 18:39 +0100
                Re: Getting Rid Of PostScript Markus Triska <triska@metalevel.at> - 2016-10-25 20:52 +0200
                Re: Getting Rid Of PostScript Alan <alan.isaac@gmail.com> - 2016-10-19 16:41 -0700
                Re: Getting Rid Of PostScript Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-10-19 17:15 -0700

csiph-web