Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 Semantics - Page 4 — Parallax Forums

Spin2 Semantics

124»

Comments

  • cgracey wrote:
    Underscores look like minus signs: - _
    Not really. They're lower and longer. There should be no confusing the two. Besides, even a bare minus sign at the end of the line could not be confused with an actual operation, so what does it matter? I say stick with the underline character for line continuation.

    -Phil

  • just do it like old school COBOL, in fixed form, any char in column 72 will force...

    Not really. Even COBOL now uses free form source without column specific meanings. I agree with @"Phil Pilgrim (PhiPi)" that underscore is OK.

    In opposite to chip and eric I still think ~ and ~~ should be supported in Spin2 to make porting more easy, why canceling a language features, Spin2 should support as much of Spin1 as possible.

    Mike
  • cgraceycgracey Posts: 14,133
    edited 2019-06-05 09:46
    msrobots wrote: »
    ...In opposite to chip and eric I still think ~ and ~~ should be supported in Spin2 to make porting more easy, why canceling a language features, Spin2 should support as much of Spin1 as possible.

    Mike

    I actually agree because of their brevity in typing. And even though they are not unique bytecodes, it only takes one more bytecode to specify the 0 or -1:
    	var~		'clear all bits in var		same as 'var\0' within expressions or 'var := 0' in isolation
    	var~~		'set all bits in var		same as 'var\-1' within expressions or 'var := -1' in isolation
    

    Thanks for pushing on this. I think this is the right thing to do. Sorry I've been so reluctant about this.
  • cgraceycgracey Posts: 14,133
    edited 2019-06-05 10:18
    I've added var~ and var~~ into the Spin2 compiler.

    This code:
    pub go(a,b)
    
      a~
      a~~
      b := a~
      b := a~~
    

    Compiles to bytecodes:
    03 - RFVAR value to advance stack by (accommodate RESULT,a,b)
    39 - push 0
    E1 - pop and write to 'a'
    38 - push -1
    E1 - pop and write to 'a'
    39 - push 0
    F1 - setup variable 'a'
    84 - read 'a' and push, swap top stack values, pop and write to 'a'
    E2 - pop and write to 'b'
    38 - push -1
    F1 - setup variable 'a'
    84 - read 'a' and push, swap top stack values, pop and write to 'a'
    E2 - pop and write to 'b'
    06 - return from pub 'go' with RESULT
    

    Viewed together:
    pub go(a,b)
    		'03		(accommodate RESULT,a,b)
      a~		'39 E1		(push  0, pop and write 'a')
      a~~		'38 E1		(push -1, pop and write 'a')
      b := a~	'39 F1 84 E2	(push  0, setup 'a', do var\x, pop and write 'b')
      b := a~~	'38 F1 84 E2	(push -1, setup 'a', do var\x, pop and write 'b')
    		'06		(return RESULT)
    

    To give some example of how much time these bytecodes take to execute:

    38/39 take 10 clocks, plus a WRLONG (3..10 clocks), for 13..20 total
    E1/E2 take 12 clocks, plus a WRLONG (3..10 clocks) and a RDLONG (9..16), for 24..38 total
    F1 takes 18 clocks
    84 takes 18 clocks, plus a WRLONG (3..10 clocks) and a RDLONG (9..16), for 30..44 total

    It's not as fast as PASM, but it's way faster than Spin1 on Prop1.
  • TorTor Posts: 2,010
    edited 2019-06-05 10:35
    I hope the ~ symbol can be avoided as much as possible, or not used at all. For European users that key is in the 'deadkeys' group by default, which means that when you press the key and release it nothing happens, until you press another key. ~~ is therefore extra tricky and bothersome to type. In the C language it's only used as an operator for 'bitwise not', i.e. rarely, so it's not too much of an issue.
    I personally have no problems with it on my personal computers because I know how to reprogram they keyboard. But for most people it would be a hassle if it's used for something common.
  • I myself have no problem with the tilde "~". On my german QWERTZ keyboards, it's on AltGr + +.
    I DO have a problem with the caret "^", because that's a deadkey for me, where you have to press it twice, but that actually inserts TWO of the damn things "^^". So you have to backspace over the second one.
  • cgracey wrote: »
    Which is better?
    CLKSET(clkmode,clkfreq)
    
    -or-
    CLKSET(clkfreq,clkmode)
    

    It really doesn't make much difference, so I would suggest keeping it the same as Spin1.
  • cgraceycgracey Posts: 14,133
    ersmith wrote: »
    cgracey wrote: »
    Which is better?
    CLKSET(clkmode,clkfreq)
    
    -or-
    CLKSET(clkfreq,clkmode)
    

    It really doesn't make much difference, so I would suggest keeping it the same as Spin1.

    Okay. Thanks, Eric.
  • cgracey wrote: »
    koehler wrote: »
    My brother Ken is flying back from a teacher training he just did in Chicago and they used MicroBit Python over the web. The teachers loved it because no app was required. Having teachers and students install apps to do something is always a protracted nightmare.

    As someone else eluded too, teachers like many others will take the path of least resistance.

    If P2 wants to be somewhat useful in the .edu, then something like self-hosted Python or via web somehow would seem to be one way to go forward since it obviates the need to install IDE's, compilers, etc.
    Anything else in the .edu sphere nowadays would most likely be seen as a step back to the old ways of doing things, and .edu instructors are going to latch on to whatever is the least painful way forward I would think.
    So thats edu sorted.

    On the enthusiast side of things, or Maker, or whatever, Spin2 is still going to be somewhat niche. However would seem to me to be best to take the opportunity to move ahead with any changes which P2 needs vs trying to retain dogmatic Spin1 compatability at the expense of P2. Unless Spin2 has a requirement for a certain syntax/glyph, etc, would seem like migrating to something a bit more 'standard' in the programming field insofar as notation, order of preference/execution, etc would only help Spin2 be easier to pickup, or been seen as possibly be worth the effort.
    Since C is available, I would still expect that to be preferentially picked up since the stackexchange's and google are full of far more examples/help.

    This time around, I'm hoping Parallax picks a one-two punch of C/Python upon introdution vs Spin/Spin2. Much less chance of immediately having P2 binned at the outset by someone.

Sign In or Register to comment.