Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 Operator Syntax - Page 15 — Parallax Forums

Spin2 Operator Syntax

11213151718

Comments

  • Cluso99Cluso99 Posts: 18,066
    edited 2017-04-17 19:17
    FWIW Back in the days, many mainframes used EBCDIC, not ASCII.

    I designed and sold boxes that allowed EBCDIC and ASCII computers to exchange data files.
  • Heater.Heater. Posts: 21,230
    kwinn,
    That "ingraining" had a starting point, so is it not reasonable to expect that someone who wants to program computers would have to learn to use the symbols and functions needed.
    I'm not sure I follow what you mean there.

    Are you suggesting that we should be able to take somebody who cannot read or write, who has no familiarity with any elementary maths or arithmetic or even numbers, who has no idea what a logical thought is ( A typical modern day teenager perhaps :) ) and get them programming?

    And what language or programming system would we have to use? Some new emoji language?

    As simple as Spin is I don't think it is that.

  • I doubt that the ASCII designers were the cause of * and /. (Extended ASCII actually includes × and ÷.) No, we have Herman Hollerith to "blame." His code was adopted by IBM for their punch cards, then along came Fortran, which used * and /. The rest is history.

    But IBM did not sit on a small character set for long, for then came APL. It had a huge set of cryptic operators (which operated right-to-left). An APL program looked almost runic. Keith's keyboard above shows some of the symbols used by APL. Here's a sample APL program:

    matrix.jpg

    Kinda makes interpreting Spin code seem like reading an English primer by comparison, doesn't it?

    -Phil
    Yes, that's it! Bring back the APL character set! As I recall some of the operators had to be created by overstriking one character on top of another.

  • Heater.Heater. Posts: 21,230
    Can you imagine what the creator of APL would have done if he had Unicode at his disposal?

    The mind boggles.

    Is it so that APL did not understand lower case text?
  • jmgjmg Posts: 15,140
    edited 2017-04-18 00:25
    I have no problem with REM and MOD if both are implemented.
    Both works for me too...
    Other languages already do this, so this has historic usage.
    dMajo wrote: »
    Perhaps I have lost something but REM for me is remark, ie comment. This is also the first things that appear if I google for it.
    And this is the reason that when I see REM the first thing I think of is comment.

    Perhaps, if REM is the very first thing on that line, but context should very quickly alert any reader REM is not remark/comment

    ie Could anyone read
    Digit := Result REM 10
    and sensibly think REM 10 was a comment ?


    A slightly smarter Google of
    programming REM as remainder finds 767,000 results
    programming REM as comment finds 387,000 results.
  • Heater.Heater. Posts: 21,230
    edited 2017-04-17 22:17
    I do hope you are not suggesting REM also be a SPIN comment marker?

    Anyway, to answer your question, yes. If I know that REM introduces a comment then I would expect it to at least work like //

    Digit := Result REM 10

    Should produce code like

    Digit := Result

    Ah you say, context is everything. Sure. That's another thing for a poor soul to remember. Great.



  • jmgjmg Posts: 15,140
    Heater. wrote: »
    I do hope you are not suggesting REM also be a SPIN comment marker?
    Of course not, where did I say that ?

    I was merely showing REM is not widely expected to be comment, and even someone with prior-bias (ie they have never seen REM as remainder and have been in a cave programming only in old dialects of BASIC for 30 years), can easily correct by simply scanning source code.
    No user-manual look-up is needed.






  • Heater.Heater. Posts: 21,230
    I know, you did not say that REM should be a comment marker. Just hinting that it would be OK if it was. I that worry such ideas might get taken seriously!

    User manual look up would indeed be needed if you hand no previous idea what REM might be. Then you would have to remember that it means different things in different places.

    All these details are small and easily understandable by themselves. Put enough of them together and you have C++. Which isn't.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2017-04-17 22:44
    heater wrote:
    Is it so that APL did not understand lower case text?
    Probably so. All the glyphs had to fit on a Selectric typeball. Still, they did not all fit, hence the overstrikes that David refers to. IIRC, they were done automatically by the computer that the Selectric was connected to. You did not have to type them yourself.

    -Phil
  • Heater.Heater. Posts: 21,230
    Finally I get the idea.

    APL was all about promoting sales of golf ball printers!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2017-04-17 23:01
    The APL characters had quaint names, too, like "floor," "ceiling," and "picture."

    -Phil
  • RaymanRayman Posts: 13,797
    Hadn't heard of APL, very interesting.
    Great for math and vectors.
    Fortran probably replaced it, I'd guess.

    There used to be a lot of weird languages. Now, they are all C...
  • Heater.Heater. Posts: 21,230
    Rayman,
    There used to be a lot of weird languages. Now, they are all C...
    No, no, never fear. There are lot's of new "Not C" weird languages:

    https://www.scala-lang.org/

    https://www.haskell.org/

    Might even say that weird languages are on the rise.


  • RaymanRayman Posts: 13,797
    So, the first one's description sounds just like C++.
    The second one looks like Python.

    I suppose Python is an oddball. Definitely not C, but having a surge of popularity...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2017-04-17 23:30
    Rayman wrote:
    Hadn't heard of APL, very interesting.
    Great for math and vectors.
    Fortran probably replaced it, I'd guess.
    APL came well after Fortran. But, yes, Fortran retained its ascendency as a math processing language for scientists.

    -Phil
  • If Unicode characters are a serious option then why not use something like ⦑ (U+2991) and ⦒ (U+2992) ?

    Equally, the Parallax font includes some symbols that might be appropriate, but I haven't worked out how to show them correctly here. When I paste them they look like this ≤ and ≥, but in the Parallax font they are vertical bars with left and right horizontal bars respectively. In the Propeller manual these appear below lowercase t and u respectively.

    Either of these can give an infix notation that shouldn't clash with other languages, and of course those that prefer function notation can easily create functions to hide this detail.

    Regards,
    Anthony.
  • RaymanRayman Posts: 13,797
    edited 2017-04-17 23:35
    Google trends might be an interesting way to judge interest in a language...

    Python comes in ~15% compared to C++, pretty impressive. But, JavaScript (what I'd call a C based language) also gets ~15%.

    Fortran is at 0%.

    Delphi and Pascal <4%
  • jmgjmg Posts: 15,140
    AJL wrote: »
    If Unicode characters are a serious option then why not use something like ⦑ (U+2991) and ⦒ (U+2992) ?

    Are they a serious option ?
    AJL wrote: »
    Equally, the Parallax font includes some symbols that might be appropriate, but I haven't worked out how to show them correctly here. When I paste them they look like this ≤ and ≥, but in the Parallax font they are vertical bars with left and right horizontal bars respectively. In the Propeller manual these appear below lowercase t and u respectively.
    Hmm, I doubt anyone thinks requiring a special font, before you can hope to read source code is 'a good idea'.
    That just epitomizes bad, non-portable language design - even TABs are grumbled about on here, as being non-portable!

  • kwinnkwinn Posts: 8,697
    Cluso99 wrote: »
    FWIW Back in the days, many mainframes used EBCDIC, not ASCII.

    I designed and sold boxes that allowed EBCDIC and ASCII computers to exchange data files.

    Those were the not so fun days. I had to build an interface to receive serial ascii data from a mini and output parallel ebcdic and control signals to a keypunch for a university library science department, and the keypunch still had to work from the keyboard. That was before micro's or eproms.
  • kwinnkwinn Posts: 8,697
    Heater. wrote: »
    kwinn,
    That "ingraining" had a starting point, so is it not reasonable to expect that someone who wants to program computers would have to learn to use the symbols and functions needed.
    I'm not sure I follow what you mean there.

    Are you suggesting that we should be able to take somebody who cannot read or write, who has no familiarity with any elementary maths or arithmetic or even numbers, who has no idea what a logical thought is ( A typical modern day teenager perhaps :) ) and get them programming?

    And what language or programming system would we have to use? Some new emoji language?

    As simple as Spin is I don't think it is that.

    No, I was not referring to the typical modern day teenager ;-)

    I was referring to the typical modern day geek who was interested in learning to program computers. I would think that expecting them to learn the meaning of a few more symbols is not too unreasonable.
  • jmg wrote: »
    AJL wrote: »
    If Unicode characters are a serious option then why not use something like ⦑ (U+2991) and ⦒ (U+2992) ?

    Are they a serious option ?
    Only Chip can answer that.
    jmg wrote: »
    AJL wrote: »
    Equally, the Parallax font includes some symbols that might be appropriate, but I haven't worked out how to show them correctly here. When I paste them they look like this ≤ and ≥, but in the Parallax font they are vertical bars with left and right horizontal bars respectively. In the Propeller manual these appear below lowercase t and u respectively.
    Hmm, I doubt anyone thinks requiring a special font, before you can hope to read source code is 'a good idea'.
    That just epitomizes bad, non-portable language design - even TABs are grumbled about on here, as being non-portable!

    How portable do we expect any version of Spin to be?
    Some OBEX objects include circuit diagrams or waveforms, and there's no hope of reading these without the Parallax font, yet they are in many cases critical to understanding of the function or purpose of the code.

    If the characters in the Parallax font turn out to be ≤ and ≥ in other fonts it's better than non-printing characters, or something with completely different shapes and not in opposites.
    jmg wrote: »
    Err, has everyone fully grasped this new !< !> syntax now imposes restrictions on the operator order ?
    That restriction was not there on the old syntax.
    If you say 'Hey, let's allow either order', in one case the opcode does not do what it literally says.
    Which repeats the problem of backwards MIN, where what happens is not what the code says..

    There is also a restriction on operator order for subtraction and division, for good reason. I don't think the restriction on operator order is a problem.

    I think we are spinning our wheels here for no real reason, as I believe Chip has settled on !< and !>.

    Regards,
    Anthony.
  • This whole discussion has gone off the deep end.
  • Roy Eltham wrote:
    This whole discussion has gone off the deep end.
    Yes, but like most lemmings, we're absolutely certain that we can fly! :)

    -Phil
  • jmgjmg Posts: 15,140
    AJL wrote: »
    How portable do we expect any version of Spin to be?
    I'm sure Ken will answer Very Portable!
    Their education market has a very wide range of input devices now.
    AJL wrote: »
    Some OBEX objects include circuit diagrams or waveforms, and there's no hope of reading these without the Parallax font, yet they are in many cases critical to understanding of the function or purpose of the code.
    Surely that is now deprecated, and in a serious manner.
    Tried posting that to the forum, for example ?
    I've not found any circuit diagrams or waveforms I could not render fine in Courier Font.
    jmg wrote: »
    Err, has everyone fully grasped this new !< !> syntax now imposes restrictions on the operator order ?
    That restriction was not there on the old syntax.
    AJL wrote: »
    ... I don't think the restriction on operator order is a problem.

    My key point was, that restriction is new, it was not there before.
    That means simple translation from Spin1 to Spin2, is no longer quite so simple..

    Maybe all hope of harvesting Spin1 was lost some time back, but to me it seems important to try to have some easily equivalent mapping, as many of the improvements could easily back-apply to Spin1.5 (ie that means improved syntax Spin, running on P1)
  • Heater.Heater. Posts: 21,230
    Rayman,
    ...JavaScript (what I'd call a C based language)...
    Ouch! Red rag to a bull :)

    Javascript has an uncanny visual, syntactic, similarity to C. What with having some same keywords, operators, block structure and curly braces.

    Javascript is however semantically nothing like C. C does not have dynamic typing, objects, prototypical inheritance, first class functions, closures, lambdas, etc.

    Javascript is as much like C as Python is. Javascript is many levels of abstraction away from C, owing more of it's heritage to the Self language.

  • I've been loosely following this discussion; I think that's the best way to follow it

    To me !> is good because for most people 'taking a stab' at its meaning (without looking up docs) would yield the correct result

    There's no need to be fully backwards compatible, main thing is we get the same joy programming a P2 as we did P1. Without the constraint of full compatibility, taking the opportunity to fix the worst of P1 makes sense.

  • Heater.Heater. Posts: 21,230
    OK, I'll take a stab at it:

    "!>" means "not greater than". It's a comparison operator that returns true if the thing on the left
    is not greater than the thing on the right.

    No?

  • TubularTubular Posts: 4,620
    edited 2017-04-18 06:04
    Keep stabbing...

    I'm still ok with it though, because I think the meaning would be clear from its context

    I think its a quirk with having
  • AribaAriba Posts: 2,682
    edited 2017-04-18 16:37
    Heater. wrote: »
    OK, I'll take a stab at it:

    "!>" means "not greater than". It's a comparison operator that returns true if the thing on the left
    is not greater than the thing on the right.

    No?

    So "|=" means "or-equal to", ">>" means "much greater than".

    No ?


  • TorTor Posts: 2,010
    In any case: Operators are of course a useful programming concept. Not so much, in my opinion, when you stretch that to multi-operator semantics to achieve your one-operation result (clamp a value).
Sign In or Register to comment.