Shop OBEX P1 Docs P2 Docs Learn Events
Spin slang? — Parallax Forums

Spin slang?

cavelambcavelamb Posts: 720
edited 2012-01-31 07:58 in Propeller 1
Where did := come from?

I've not seen that in other languages (but I may be a few years out of date now).

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-30 10:00
    Languages designed by Niklaus Wirth (Pascal, Modula 2) use := . But those roots go back to Algol, which also used := .

    -Phil
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 10:16
    Thanks, that gives me a google trail.
    Looking for := by itself turned up nada...
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 10:18
    I thought Pascal used =: rather than :=
  • LeonLeon Posts: 7,620
    edited 2012-01-30 10:19
    Pascal uses both.
  • lyassalyassa Posts: 52
    edited 2012-01-30 13:44
    I really wish that Spin used "=" instead of ":=", and "{' and "}" instead of indentation.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-30 13:54
    There really are three kinds of "equal", and each deserves it's own operator:
    1. Declaration =, as used in the CON section
    2. Assignement :=
    3. Test for equality ==

    These not only help to disambiguate expressions, but they help to make sure that you mean what you've written.

    -Phil
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-01-30 13:58
    You forgot to mention ===
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-01-30 14:02
    Oh, and then there's +=, -=, *=, <#=, #>=, ... wait I need to consult the Prop manual ...

    **=, /=, //=, ~>=<<= >>= <-=, ><=, &=, |=, ^=, AND=, OR=, <>=, <=, >=, =<= and =<=

    Oh, and =>, =<

    and finally <>, which is the only "equals" operation that does not use the "=" character.
  • pedwardpedward Posts: 1,642
    edited 2012-01-30 14:07
    I personally think that = vs := is a silly distinction. You cannot reassign a constant, most compilers puke when you try that, even C tells you in very clear error messages.

    If SPIN used (F)LEX and YACC for the lexer and tokenizer, then = and := are free and require no overhead. However, since the compiler is written long-hand, it requires additional tokens and checks.

    = is assignment
    == is evaluation
    === is evaluation and type checking

    === in PHP basically says "if A evaluates to the same value as B and they have the same type, then the expression is true". This only matters when you have trinary: True, False, and NULL. In PHP a NULL evaluates to False and non-existent evaluates to False. If you compare values and one of them is not defined/declared, it can be detected with === instead of the more obvious isset() or isempty(). Also, if you are trying to detect a type mismatch in your data, the === operator is useful.
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 17:26
    Another thing that tripped me up for a moment was ~ and ~~.
    Not and Not not?

    But other than that (and the indentation forming the structure - for an hour or so) Spin seems usable.
    I got Blinky running - with a button that changes the blink rate - in one evening.
    The obvious problem (in hind sight) was that waitCnt took 58 seconds or so no matter what - until I started indenting to make the structure clearer.
    Then I noticed what was happening.
    Cute. Really cute... it does work though.

    I haven't started playing with Assembly yet.
    What I've seen in the examples looks right readable.

    It's an interesting platform.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 17:32
    cavelamb wrote: »
    It's an interesting platform.
    Good to see another person examining it. Any interesting projects in mind?
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 21:12
    Good to see another person examining it. Any interesting projects in mind?

    I have a couple of projects in mind, but I don't know how "interesting" they would be to the rest of the world.

    First one is a simple thing... a ships bell.

    I'm a sailor, and while the geek in me appreciates Christopher Miller's sailboat, "Spin",
    I'd rather just sail the boat my own bad self. I'm not anti-geek at all, but I appreciate
    simplicity a lot more these days. However, simplicity can mean many things.
    Taken to an extreme it could mean no gadgetry at all (Ludism wrote small?),
    or in moderation it might mean simplicity of operation.
    I like the latter. It lets me use the GPS and autopilot without internal conflict.

    I'd like to have the bells aboard my boat. (and at home too, but especially aboard the boat)
    It marks the passage of time through the day.

    Waste of processor power, maybe, but that's my first gig.

    Bells.

    I see two approaches.
    First is the simplest, hit a real brass bell with a real solenoid driven hammer.
    Nothing sweeter than the hard attack and slow decay of a real brass bell.
    Make a nice walnut base to hide all the bytes and bits...
    M'lady might even let me keep it in the house?

    The other is to digitize that sound and and play it back - wave or MP3 style.
    Maybe not as nice to look at, but there are some important advantages.

    Either way, time keeping is at the heart of the project.
    To that end I've been studying the RTC modules available.
    I bought a DS1307 module from Sparks and have been reading driver code for it.
    (BTW, bless all who have posted their works in the Object Exchange! You guys rock!)
    Should be a straight forward job on a Parallax Proto board - with a 5 volt regulator on board.
    I2C or SPI, doesn't seem to make much difference in this limited application.
    Our pins runneth over.

    But now I'm thinking power supplies, and think that maybe the thing could run from batteries.

    I have to look mode closely at the 3.3 volt chips like the Dallas DS3234.
    Sparkfun has one, and Adafruit has their ChronoDot.

    The stumper for a long time was how to set the time - with minimal extra circuitry.
    Minimal.
    That means (to me) no display, no keyboard, no handy computer, no smart phone, and no extra IQ required.
    I figured it out, one bit, and it's a traditional naval solution to boot!

    The next problem to solve (for the block 1 project) is the hammer actuator.
    A solenoid is the most obvious choice, but a suitable one seems to be illusive at present. Still looking there.

    I almost think there is a way to do it with a servo and rubber band (or spring), but I haven't really worked it out yet.
    The two strokes a second apart gets to be a challenge using something that slow.

    For block 2, recording the sounds and massaging them into something compatible could be just as challenging.
    And probably a lot more frustrating too. That's a pure ignorance issue on my part.
    What works with what?
    But it would make a more compact and self contained unit.
    And less strenuous power supply issues to boot.
    I bought a Gadget Ganster Platform USB board for that one since it has an on-board SD card socket.
    That long rolling decay ain't gonna fit in any 32k of EEPROM space.

    Oh well, it keeps me busy.
    And it really is an interesting platform...
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 22:08
    cavelamb wrote: »
    ... Waste of processor power, maybe, but that's my first gig.
    It's better than a fancy blinky light, but that's what I have running on my desk right now, though I am building a high-power motor controller.
    cavelamb wrote: »
    Bells.

    I see two approaches.
    First is the simplest, hit a real brass bell with a real solenoid driven hammer.
    Nothing sweeter than the hard attack and slow decay of a real brass bell.
    Make a nice walnut base to hide all the bytes and bits...
    M'lady might even let me keep it in the house?

    The other is to digitize that sound and and play it back - wave or MP3 style.
    Maybe not as nice to look at, but there are some important advantages.
    The propeller is actually better at synthesis than it is at audio playback.
    cavelamb wrote: »
    Either way, time keeping is at the heart of the project.
    To that end I've been studying the RTC modules available.
    I bought a DS1307 module from Sparks and have been reading driver code for it.
    (BTW, bless all who have posted their works in the Object Exchange! You guys rock!)
    Should be a straight forward job on a Parallax Proto board - with a 5 volt regulator on board.
    I2C or SPI, doesn't seem to make much difference in this limited application.
    Our pins runneth over.

    But now I'm thinking power supplies, and think that maybe the thing could run from batteries.

    I have to look mode closely at the 3.3 volt chips like the Dallas DS3234.
    Sparkfun has one, and Adafruit has their ChronoDot.

    The stumper for a long time was how to set the time - with minimal extra circuitry.
    Minimal.
    That means (to me) no display, no keyboard, no handy computer, no smart phone, and no extra IQ required.
    I figured it out, one bit, and it's a traditional naval solution to boot!
    Since you don't expand on this, I'll have to assume that you're tapping into the NMEA data bus in your equipment box and grabbing GPS timestamp data.
    cavelamb wrote: »
    The next problem to solve (for the block 1 project) is the hammer actuator.
    A solenoid is the most obvious choice, but a suitable one seems to be illusive at present. Still looking there.
    5 volts, or 36 volts?
    cavelamb wrote: »
    ...

    For block 2, recording the sounds and massaging them into something compatible could be just as challenging.
    And probably a lot more frustrating too. That's a pure ignorance issue on my part.
    What works with what?
    But it would make a more compact and self contained unit.
    And less strenuous power supply issues to boot.
    I bought a Gadget Ganster Platform USB board for that one since it has an on-board SD card socket.
    That long rolling decay ain't gonna fit in any 32k of EEPROM space.
    You may wan to look into some of the Karplus-Strong synthesis that's been discussed on this forum.
    cavelamb wrote: »
    Oh well, it keeps me busy.
    And it really is an interesting platform...
    That actually sounds like fun.
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 22:26
    Circuitsoft;1070629]It's better than a fancy blinky light, but that's what I have running on my desk right now, though I am building a high-power motor controller.

    I have one of those too!
    I love my blinky LED.
    It even does trick (that's like tricks, but it only has one)


    The propeller is actually better at synthesis than it is at audio playback.

    It's all in the attach, sustain and decay.
    If there is a guru that can explain ot in simple terms, I'll sit and learn.


    Since you don't expand on this, I'll have to assume that you're tapping into the NMEA data bus in your equipment box and grabbing GPS timestamp data.

    NEMA??!!!?!?! ROTFLMAO!
    Nope! I mean seriously - THAT'S some serious extra circuitry.
    No, what I have in mind is a single bit.
    Although one could use a sextant if necessary, but it's still just one bit.
    Cluso will get it.


    5 volts, or 36 volts?

    Oh golly, 6 volts off of a battery pack?
    The boat's electrical system is 12 volts but I'd really prefer it to be more portable than that.


    You may wan to look into some of the Karplus-Strong synthesis that's been discussed on this forum.

    Haven't seen it yet, but will look it up.
    Thanks.

    Another possibility is a small MP3 player? I saw one posted here the othe night.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 22:48
    cavelamb wrote: »
    ...
    Nope! I mean seriously - THAT'S some serious extra circuitry.
    Not really, unless you don't already have a GPS on the boat. NMEA0183 is just RS422@4800 baud. For input only, that would (technically) be one bit.
    cavelamb wrote: »
    No, what I have in mind is a single bit.
    Although one could use a sextant if necessary, but it's still just one bit.
    Is the single bit sun visible vs sun not visible? Does that just allow you to find when noon is?
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 23:02
    Not really, unless you don't already have a GPS on the boat. NMEA0183 is just RS422@4800 baud. For input only, that would (technically) be one bit.

    Huh, ok, fair enough. Ya got me on that one.
    But I don't have GPS at home.
    This is Texas. It doesn't move that much.
    Let's rule that out.

    Is the single bit sun visible vs sun not visible? Does that just allow you to find when noon is?

    No - on a technicality.
    It doesn't "allow us to find when noon is". But warm. Very warm.

    The naval day begins at noon - because that is the only time of the day that one can be sure of at sea.
    By observing the sun's altitude (with a sextant) we can determine the exact time of local noon.
    The sun rises, then rises no more, then she starts back down...

    Now note that this is local noon. Very important.
    Because the time hack on the WWV radio hack (or even GPS, I think) is Greenwich time - not local.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 23:05
    Yes, WWVB and GPS are both GMT, but adding your time-zone is easy enough. I guess I thought you were putting this on your boat.

    To do anything other than sun-visible-or-not, you'd also need to know what angle the sextant is set to, so that's a lot more than 1 bit, isn't it?
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 23:12
    Yes, WWVB and GPS are both GMT, but adding your time-zone is easy enough. I guess I thought you were putting this on your boat.

    To do anything other than sun-visible-or-not, you'd also need to know what angle the sextant is set to, so that's a lot more than 1 bit, isn't it?

    Nope. Well, not if you can use a sextant. Or a watch.
    Which is, by my own rules, cheating, I guess. The watch anyway.

    No, just one button - press it at noon.
    Code sets the RTC chip to - noon - when pressed.
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2012-01-30 23:27
    It would be cooler if you had a motorized sextant with a light sensor and an encoder on the angle measure... :)
  • cavelambcavelamb Posts: 720
    edited 2012-01-30 23:36
    It would be cooler if you had a motorized sextant with a light sensor and an encoder on the angle measure... :)

    That would indeed be something to see!

    Check out the history of John Harrison - clock maker...
    http://en.wikipedia.org/wiki/John_Harrison

    The sextant hasn't changes much since the 18th century.
    But time keeping sure has.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-31 00:17
    cavelamb wrote:
    Check out the history of John Harrison - clock maker...
    The book, Longitude by Dava Sobel is a must read!

    -Phil
  • Mark_TMark_T Posts: 1,981
    edited 2012-01-31 07:58
    pedward wrote: »
    I personally think that = vs := is a silly distinction. You cannot reassign a constant, most compilers puke when you try that, even C tells you in very clear error messages.

    Basically the distinction is between declarative and imperative programming, its actually pretty important theoretically and in real compilers on real hardware.

    The truth is that := was the assignment operator in nearly all computer languages except Fortran. Then C came along and borrowed Fortran's syntax. The ":=" operator is designed to be read as "set equal to", where as "=" reads as "equals"... The Algol family also had the LET statement to introduce 'constant' variables using '=' rather than ':=' ie "LET a = b * 2 ;" (which is not an assignment).
Sign In or Register to comment.