Git Product home page Git Product logo

Comments (7)

SamWindell avatar SamWindell commented on August 28, 2024

uh oh :/
Let me take a look.

from sublimeksp.

SamWindell avatar SamWindell commented on August 28, 2024

Actually I don't think this is a new bug. Have you only just started using a divide in the define value? It's bad news if this update is breaking people's code, but I'm not sure that that is the case.

Nevertheless, a silly bug to miss, I will fix this tomorrow.

from sublimeksp.

eitherys avatar eitherys commented on August 28, 2024

No, it was working fine earlier.

Here is an example line:

define NUM_ARTIC_PGS_KEYS := ((DATA_ARRAY_SIZE / PGS_MAX_KEY_LENGTH) + ((DATA_ARRAY_SIZE % PGS_MAX_KEY_LENGTH)+(PGS_MAX_KEY_LENGTH-1))/PGS_MAX_KEY_LENGTH)

Without getting into nitty gritty implementation details (not discussing design practices, just showing code that is breaking) or why I wrote this code the way it is, what's happening is that it's finding the next factor up from the size of the data array as a multiple of PGS key length.

For example, 2048 size would create 16 PGS keys, while 2049 (all the way up to 2176) size would make 17 PGS keys to accommodate the data. The idea is we might be defining different data sizes per project, and so it's nice to use iterate macro to create and update pgs keys for transferring this data array instead of manually adding and removing them each project.

I know it seems like an absurd thing to want to do but the easiest specific example I could provide is something I'm actually doing. :)

ANYWAYS, the point is this compiled fine a week ago, and worked beautifully.

Example program:

on init
    define ARTIC_MATRIX_SIZE := 2112
    define PGS_MAX_KEY_LENGTH := 128
​
    declare ARTIC_MATRIX[ARTIC_MATRIX_SIZE]
​
    articulations.ui.createPGSKeys
    articulations.ui.updatePGSKeys
end on
​
define ITERATES.ON_PGS_KEY_NUMS := #0 to ((ARTIC_MATRIX_SIZE / PGS_MAX_KEY_LENGTH) + ((ARTIC_MATRIX_SIZE % PGS_MAX_KEY_LENGTH)+(PGS_MAX_KEY_LENGTH-1))/PGS_MAX_KEY_LENGTH) - 1#
​
macro articulations.ui.createPGSKeys()
    iterate_macro(pgs_create_key(ARTIC_PGS#n#, PGS_MAX_KEY_LENGTH)) := ITERATES.ON_PGS_KEY_NUMS
end macro
​
macro articulations.ui.updatePGSKeys()
    declare i
    for i := 0 to PGS_MAX_KEY_LENGTH - 1
        iterate_macro(send_PGS_key) := ITERATES.ON_PGS_KEY_NUMS
    end for
end macro
​
macro send_PGS_key(#n#)
    if #n#*PGS_MAX_KEY_LENGTH + i < ARTIC_MATRIX_SIZE
        pgs_set_key_val(ARTIC_PGS#n#, i, ARTIC_MATRIX[#n#*PGS_MAX_KEY_LENGTH + i])
    end if
end macro

and compiled result:

{ Compiled on Fri Jul  1 11:05:56 2016 }
on init
declare %ARTIC_MATRIX[2112]
pgs_create_key(ARTIC_PGS0,128)
pgs_create_key(ARTIC_PGS1,128)
pgs_create_key(ARTIC_PGS2,128)
pgs_create_key(ARTIC_PGS3,128)
pgs_create_key(ARTIC_PGS4,128)
pgs_create_key(ARTIC_PGS5,128)
pgs_create_key(ARTIC_PGS6,128)
pgs_create_key(ARTIC_PGS7,128)
pgs_create_key(ARTIC_PGS8,128)
pgs_create_key(ARTIC_PGS9,128)
pgs_create_key(ARTIC_PGS10,128)
pgs_create_key(ARTIC_PGS11,128)
pgs_create_key(ARTIC_PGS12,128)
pgs_create_key(ARTIC_PGS13,128)
pgs_create_key(ARTIC_PGS14,128)
pgs_create_key(ARTIC_PGS15,128)
pgs_create_key(ARTIC_PGS16,128)
declare $i
$i := 0
while ($i<128)
if (0+$i<2112)
pgs_set_key_val(ARTIC_PGS0,$i,%ARTIC_MATRIX[0+$i])
end if
if (128+$i<2112)
pgs_set_key_val(ARTIC_PGS1,$i,%ARTIC_MATRIX[128+$i])
end if
if (256+$i<2112)
pgs_set_key_val(ARTIC_PGS2,$i,%ARTIC_MATRIX[256+$i])
end if
if (384+$i<2112)
pgs_set_key_val(ARTIC_PGS3,$i,%ARTIC_MATRIX[384+$i])
end if
if (512+$i<2112)
pgs_set_key_val(ARTIC_PGS4,$i,%ARTIC_MATRIX[512+$i])
end if
if (640+$i<2112)
pgs_set_key_val(ARTIC_PGS5,$i,%ARTIC_MATRIX[640+$i])
end if
if (768+$i<2112)
pgs_set_key_val(ARTIC_PGS6,$i,%ARTIC_MATRIX[768+$i])
end if
if (896+$i<2112)
pgs_set_key_val(ARTIC_PGS7,$i,%ARTIC_MATRIX[896+$i])
end if
if (1024+$i<2112)
pgs_set_key_val(ARTIC_PGS8,$i,%ARTIC_MATRIX[1024+$i])
end if
if (1152+$i<2112)
pgs_set_key_val(ARTIC_PGS9,$i,%ARTIC_MATRIX[1152+$i])
end if
if (1280+$i<2112)
pgs_set_key_val(ARTIC_PGS10,$i,%ARTIC_MATRIX[1280+$i])
end if
if (1408+$i<2112)
pgs_set_key_val(ARTIC_PGS11,$i,%ARTIC_MATRIX[1408+$i])
end if
if (1536+$i<2112)
pgs_set_key_val(ARTIC_PGS12,$i,%ARTIC_MATRIX[1536+$i])
end if
if (1664+$i<2112)
pgs_set_key_val(ARTIC_PGS13,$i,%ARTIC_MATRIX[1664+$i])
end if
if (1792+$i<2112)
pgs_set_key_val(ARTIC_PGS14,$i,%ARTIC_MATRIX[1792+$i])
end if
if (1920+$i<2112)
pgs_set_key_val(ARTIC_PGS15,$i,%ARTIC_MATRIX[1920+$i])
end if
if (2048+$i<2112)
pgs_set_key_val(ARTIC_PGS16,$i,%ARTIC_MATRIX[2048+$i])
end if
inc($i)
end while
end on

(granted I have changed the details of how the program works and optimized it and made some corrections, but the core method is the same, using defines and division and such)

from sublimeksp.

eitherys avatar eitherys commented on August 28, 2024

So it did work before, but now it does not. Now it compiles to error, because those define constants are now placing decimals.

from sublimeksp.

SamWindell avatar SamWindell commented on August 28, 2024

PGS variables are limited by their size so that's a cool way to work around that :)

Whatever has happened, I am confident that this bug is not a result of the latest update. The culprit is a line that evaluates the define statement's value as a python expression which foolishly of course can result in floats when doing division. But this line has been present for many releases, if one was so inclined this can be checked in github release history.

Somehow it has surfaced itself over time, which I am pleased because this one is a nasty one!

from sublimeksp.

eitherys avatar eitherys commented on August 28, 2024

Strange that it wasn't an issue before. It can't be my own error, as I showed a program did properly compile with these very operations. The only thing scarier than not knowing why something doesn't work is not knowing why it works. D:

Good to know you found the culprit line, though. Can put it to rest, at least.

from sublimeksp.

SamWindell avatar SamWindell commented on August 28, 2024

This is going to take longer to fix than I thought.
In the mean while, if you are desperate to get it back working again, you could use the python function int() to make your divides cast to integers. Like: int(ARTIC_MATRIX_SIZE / PGS_MAX_KEY_LENGTH)

This is a bit hacky and I can't guarantee that this will still work after the update, but might be useful if you need it now.

from sublimeksp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.