const declaration: enforced, or just a formality?

Am I to understand that DazScript is loosely-typed enough that declaring a const is just a fancy way of saying "this is only a constant if you believe it is"? cheeky

I'm using CAPSLOCK convention for naming my constants, so I'm not particularly worried about preservation where my own hand is concerned, but if I pass my framework to someone else...

 

Is there any true constant declaration, or am I just expecting C out of DazScript? I also noticed that the script really doesn't even care if you declare var, pretty much any token can take any value at any time, regardless. Not that I have a problem with it, but I'm used to relying more on stronger type and less concentration on naming convention to mitigate my fuzzier exceptions. I'm not a fan of finding out waaay down the line that even though I named it sFoo, I passed it a pointer to Bar rather than its Name. angry

Comments

  • As I recall const no longer does anything, it was one of the changes from QSA to Qt Script.

  • Richard HaseltineRichard Haseltine Posts: 100,871
    edited August 2021

    I am told that the DS script engine, based on ECMAScript 5.1, reserves cosnt as a future keyword - it is fortunate that it is not throwing an error or behaving in unexpected ways. QtScript was based on  ECMAScript 4 which was a proposal, rather than a final standard, and which was not adopted - that did have cosnt as a defined keyword.

    Do make sure that you are properly declaring your variables, with var, as otherwise they will be globals (even if (not) declared in a function) which can certainly lead to their behaving in unexpected ways.

    Post edited by Richard Haseltine on
  • Thanks for that tip on scope, I wan't aware of that bit.

    Yes, I make sure I know where my variables live, since I'm using just a text editor and a cup of coffee.

    Would be neat if there was Eclipse or JetBrains support for DazScript, but hey, it's not all that complicated.

  • OmnifluxOmniflux Posts: 377

    I have not tried it, but https://github.com/siblount/JzSense may work for Eclipse or JetBrains...

  • WOW I was not aware it existed, thanks!

    I'll give it a spin a little later on when I get the chance.

  • edited August 2021

    So I got a chance to grab JzSense and add it to a workspace in VSCode, and it's pretty flippin' good.

    It's by no means complete, but it sure makes using JavaScript affinity for .dsa files a workable solution to power-editing. Members are working fine across included script modules, and most of the important inline Dz docs are already included.

    Thanks again for the tip!

    Screenshot_3.jpg
    1100 x 252 - 52K
    Post edited by ghost_of_delete_key on
Sign In or Register to comment.