Menu

#562 Push/Pop extend to multiple items

3.0 Series
open
nobody
None
5
2021-12-29
2021-12-24
Greg Smith
No

Allow:
Push value [value]
...
Pop value [value}

That is, push a list of items from left to right, Pop a list of items from right to left.
This has no effect on runtime, it is just a convenience for the script so:
Push $0
Push $1
Push $2
Push $3
...
Pop $3
Pop $2
Pop $1
Pop $0

becomes:
Push $0 $1 $2 $2
...
Pop $0 $1 $2 $3

Discussion

  • Anders

    Anders - 2021-12-25

    There was already a request to allow this for Call but I think some internal discussions turned it down because we could not agree on left to right vs right to left but I suppose we can revisit the issue.

    I agree in your example here that Pop right to left gives a nice symmetry but I'm not sure if it makes sense from a language standpoint.

     

    Last edit: Anders 2021-12-25
    • Greg Smith

      Greg Smith - 2021-12-29

      Having written ARM assembly from almost the beginning, I would say that
      matching lists makes sense to me, so  left to right for push and right
      to left for pop feels natural... but you can get used to anything.
      Debates about the 'one true way' can be fun, but they really slow things
      down.

      While we are on the subject of extensions, I also miss indexed access to
      the stack... but this is a runtime change.

      Also, Exch $var1 $var2  (aka swap) would make some algorithms a bit
      easier and less verbose.... but I can see that you are a lean and mean
      machine...

      As ever, thanks for the response.

       
      • Anders

        Anders - 2021-12-29

        The System plug-in pops left to right.

        Section
        StrCpy $1 Reg$$1
        StrCpy $2 Reg$$2
        System::Store "p1 p2" ; l2r
        Exch $0
        DetailPrint $0 ; Reg$2
        Exch $0
        System::Store "r2 r1" ; l2r
        DetailPrint 1=$1 ; Reg$1
        DetailPrint 2=$2 ; Reg$2
        SectionEnd
        
         

Log in to post a comment.

MongoDB Logo MongoDB