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


Groups > comp.lang.postscript > #2925

Re: Getting Rid Of PostScript

From Carlos <angus@quovadis.com.ar>
Newsgroups comp.lang.postscript
Subject Re: Getting Rid Of PostScript
Date 2016-10-25 21:06 +0200
Organization A noiseless patient Spider
Message-ID <20161025210647.55ecd219@samara.DOMA> (permalink)
References (11 earlier) <m2bmyg6ue8.fsf@metalevel.at> <68890a35-ae58-4755-b6be-5f8a7d4b0362@googlegroups.com> <66538ba6-282f-4b3d-b8ba-94b93903385f@googlegroups.com> <nunq2l$cib$1@dont-email.me> <41c5fbb5-a268-4cc1-8522-73f92980ce69@googlegroups.com>

Show all headers | View raw


[Lawrence D’Oliveiro <lawrencedo99@gmail.com>, 2016-10-25 10:32]
> On Wednesday, October 26, 2016 at 3:26:52 AM UTC+13, Carlos wrote:
> >
> > On 25/10/2016 1:54, Lawrence D’Oliveiro wrote:
> >  
> >> Note that the actual drawing of a node is implemented by the
> >> “draw_node” function which is passed as the argument, while
> >> “draw_nodes_grid” itself only implements the layout of the entire
> >> diagram.  
> > 
> > You can do that in PostScript, too. Pass a block to a procedure,
> > then call it with exec.  
> 
> But you don’t get the lexical binding, which is what really makes
> them useful.

You can get the PostScript equivalent, as previously explained (more
below).

> >>         cell_dims = pix.dimensions / Vector(10, 10)  
> >>>  
> >> See how the x- and y-dimensions of a single cell are computed from
> >> the dimensions of the drawing area by a single division?  
> > 
> > Come on. Just because you wrote a vector library in Python and not
> > in PostScript, that doesn't make Python better.  
> 
> You didn’t notice that the operation was done with the standard
> division operator, then? Python allows you to define custom overloads
> for the standard operators. This way, you can write your expressions
> using notation much closer to the original maths.

Operator overloading is a controversial issue. Some like it, some don't.
Some think having it in a language makes it better, some think it makes
it worse. In any case, you can never write your expressions close to
mathematical notation in PostScript, so that's not a good reason to
prefer overloading. I don't think much would be gained if people could
multiply vectors using "mul" instead of "Vmul".

> 
> > assuming pix is a dictionary. Here is the start of a vector library:
> > 
> >    /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
> > 
> >    /Vdiv   { { div } Vop   } bind def  
> 
> Not much of a start, don’t you think
> <https://groups.google.com/d/msg/comp.lang.postscript/fEyXR90-wq4/AsOwYiltBgAJ>?

Just the necessary to translate to PostScript the snippets you are
posting.

> 
> > Again, a matter of libraries  
> 
> Which PostScript is, frankly, no help with.

It helps with the writing; coding in PostScript is enjoyable.

> > [Lexical binding is] a facility the Python compiler provides
> > because it's otherwise impossible to return custom functions. You
> > don't need the interpreter's help in PostScript, because procedures
> > are arrays, and you can easily create arrays programmatically. (By
> > the way, this is a recurring topic in this newsgroup lately.)  
> 
> But you cannot do the lexical binding. Not in a reentrant fashion.

Yes you can, but the interpreter won't do it automatically for you. I
just showed you! I don't know what you mean by "not in a reentrant
fashion"; if you found a case where it doesn't work please tell me.

Did you try it at all?

  GS>/add1 1 makeadder def  /add4 4 makeadder def
  GS>8 add1 add5 ==
  13


> > Try this:  
> 
> How many lines of PostScript code have you written so far? Compare it
> to how many lines of Python code I needed to write.

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

> And your solution isn’t even complete yet.

Well, you didn't post a complete solution either, just some snippets
(the code in the original message also wasn't complete). If you want,
post a complete solution and I'll try to produce a PostScript
equivalent, so you can see Python isn't better :)

-- 

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


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