microsoft / pxt

Microsoft MakeCode (PXT - Programming eXperience Toolkit)
https://makecode.com
MIT License
2.1k stars 588 forks source link

Implement multiple .blocks files #10191

Open THEb0nny opened 2 months ago

THEb0nny commented 2 months ago

Is it possible to implement several .blocks files? For example, to avoid cluttering one file with code blocks, as is done now? I think this is needed for large projects, where it becomes difficult to find code blocks. For example, you know Scratch, in which each sprite has its own code space. The problem is less exposed there. For each file, a separate ts or py file would be created. And in .menubar .editortoggle .blocks-menuitem it would be possible to select the desired file from the dropdown menu.

How do you feel about such a proposal and is it possible to implement it?

riknoll commented 1 month ago

this is a tricky problem to solve, but one that i think about occasionally as i too would love to have this feature for a few reasons.

the main issue is determining what communication between blocks files looks like. all variables in blocks are global, so do we expose all variables/functions in every file? do we want to do some sort of import/export module mechanism?

the other issue is that i believe the current codebase has a lot of assumptions about their being one blocks file in the project. would be tedious to fix

THEb0nny commented 1 month ago

@riknoll if you look at the scratch, then when creating a variable, you can choose a global variable or local (for sprite), does it seem to me adequate logic?

Maybe this opportunity should go to a large release.

riknoll commented 1 month ago

i think we would need to conduct some user studies to determine what the appropriate mental model should be for this. i do like how scratch does it, but i want to make sure we're using terminology that is easy to understand and UI that clearly differentiates the two types of variables.

in any case, i think this is probably a low priority for us right now (much as it pains me) because the vast majority of our users aren't creating projects complex enough to warrant multiple files.