Discuss Scratch
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
It will pass the variables on the current scope as arguments to the function which has been expanded.Interesting… what does the ‘summary = expand(summary)’ line do? -snip-
It is verbose but it makes the most sense and is the easiest to parse, could you suggest any alternatives?Reminds me a lot of JavaScript objects - very powerful feature - but not a very huge fan of the Standard.Object declaration. Seems a bit too verbose compared to using braces, yes? So to create an object in Sandwich you don't need to create classes first, here's how you do it.import Console
fun main() {
obj = Standard.Object(a=1, b=2, c=3)
Console.out(obj.a, obj.b, obj.c)
}1
2
3
That would imply it's in the current scope and not part of the standard scope, something like Standard.Obj might work better. object could also be a link to Standard.Object to say.Could this be a bit easier? (for example, calling `object` instead of `Standard.Object`) So to create an object in Sandwich you don't need to create classes first, here's how you do it.import Console
fun main() {
obj = Standard.Object(a=1, b=2, c=3)
Console.out(obj.a, obj.b, obj.c)
}1
2
3
And for classes.import Console
class Fruit(type) {
fun summary(type) {
Console.out("I am a fruit of type " ++ type)
}
type = type
summary = expand(summary)
}
apple = Fruit("apple")
Console.out(apple.type)
Console.out(apple.summary())apple
I am a fruit of type apple
Try out Noml!
- rdococ
- Scratcher
1000+ posts
Custom Programming Languages
Huh… I take it your functions don't capture variables from their scope automatically? It will pass the variables on the current scope as arguments to the function which has been expanded.
How about `Std.Object`, based on the C++ syntax for namespaces, `std::`? It is verbose but it makes the most sense and is the easiest to parse, could you suggest any alternatives?
- ajskateboarder
- Scratcher
1000+ posts
Custom Programming Languages
Maybe move “Object” and other datatypes into a seperate library that you specifically import? Like “import Object from Datatypes”It is verbose but it makes the most sense and is the easiest to parse, could you suggest any alternatives?Reminds me a lot of JavaScript objects - very powerful feature - but not a very huge fan of the Standard.Object declaration. Seems a bit too verbose compared to using braces, yes? So to create an object in Sandwich you don't need to create classes first, here's how you do it.
snip
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
Not their parent scope, the object. If you mean the object's scope then yes.Huh… I take it your functions don't capture variables from their scope automatically? It will pass the variables on the current scope as arguments to the function which has been expanded.
How about `Std.Object`, based on the C++ syntax for namespaces, `std::`? It is verbose but it makes the most sense and is the easiest to parse, could you suggest any alternatives?
That could work but still kinda lengthy.
Making everything an import is not what I want. I think I am going to make an operator be the constructor for object automatically like $ or % maybe.Maybe move “Object” and other datatypes into a seperate library that you specifically import? Like “import Object from Datatypes”It is verbose but it makes the most sense and is the easiest to parse, could you suggest any alternatives?Reminds me a lot of JavaScript objects - very powerful feature - but not a very huge fan of the Standard.Object declaration. Seems a bit too verbose compared to using braces, yes? So to create an object in Sandwich you don't need to create classes first, here's how you do it.
snip
Try out Noml!
- mybearworld
- Scratcher
1000+ posts
Custom Programming Languages
(#24)Maybe you can do it like Rust?
Making everything an import is not what I want. I think I am going to make an operator be the constructor for object automatically like $ or % maybe.
use std::env;
fn main() {
// Now, std::env::args can be used like so:
let args = env::args();
// However, I can also access things from std::fs, even if I have not used it,
// by fully qualifying:
std::fs::write("foo.txt", "bar").unwrap();
}
Last edited by mybearworld (Oct. 11, 2023 13:44:50)
Signatures are the only place where assets links still work.
- ajskateboarder
- Scratcher
1000+ posts
Custom Programming Languages
I'm personally not a big fan of Rust's implicit imports You should be able to know what a program uses if you just look at the top of a file Maybe you can do it like Rust?use std::env;
fn main() {
// Now, std::env::args can be used like so:
let args = env::args();
// However, I can also access things from std::fs, even if I have not used it,
// by fully qualifying:
std::fs::write("foo.txt", "bar").unwrap();
}
- mybearworld
- Scratcher
1000+ posts
Custom Programming Languages
(#26)You can still see what crates are being used in the Cargo.toml file. Details of which specific functions/structs/enums/etc are being used shouldn't be important if the crate is well designed (e.g. if every module serves one purpose).
I'm personally not a big fan of Rust's implicit imports You should be able to know what a program uses if you just look at the top of a file
Signatures are the only place where assets links still work.
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
Yeah no. So I have thought to make $ a short hand for object since it currently has no use.(#24)Maybe you can do it like Rust?
Making everything an import is not what I want. I think I am going to make an operator be the constructor for object automatically like $ or % maybe.use std::env;
fn main() {
// Now, std::env::args can be used like so:
let args = env::args();
// However, I can also access things from std::fs, even if I have not used it,
// by fully qualifying:
std::fs::write("foo.txt", "bar").unwrap();
}
So $(a=1, b=2, c=3)?
Try out Noml!
- rdococ
- Scratcher
1000+ posts
Custom Programming Languages
If you're not using square brackets for anything, how about [a=1, b=2, c=3]? Yeah no. So I have thought to make $ a short hand for object since it currently has no use.
So $(a=1, b=2, c=3)?
Last edited by rdococ (Oct. 11, 2023 18:45:17)
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
That is genius.If you're not using square brackets for anything, how about [a=1, b=2, c=3]? Yeah no. So I have thought to make $ a short hand for object since it currently has no use.
So $(a=1, b=2, c=3)?
Try out Noml!
- ajskateboarder
- Scratcher
1000+ posts
Custom Programming Languages
What would you do for lists?That is genius.If you're not using square brackets for anything, how about [a=1, b=2, c=3]? Yeah no. So I have thought to make $ a short hand for object since it currently has no use.
So $(a=1, b=2, c=3)?
- mybearworld
- Scratcher
1000+ posts
Custom Programming Languages
(#31)Maybe just [1, 2, 3]? Also, I probably missed something, is there any reason objects can't just be {a=1, b=2, c=3}?What would you do for lists?That is genius.If you're not using square brackets for anything, how about [a=1, b=2, c=3]? Yeah no. So I have thought to make $ a short hand for object since it currently has no use.
So $(a=1, b=2, c=3)?
Signatures are the only place where assets links still work.
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
Because of callbacks.(#31)Maybe just [1, 2, 3]? Also, I probably missed something, is there any reason objects can't just be {a=1, b=2, c=3}?What would you do for lists?That is genius.If you're not using square brackets for anything, how about [a=1, b=2, c=3]? Yeah no. So I have thought to make $ a short hand for object since it currently has no use.
So $(a=1, b=2, c=3)?
Try out Noml!
- mybearworld
- Scratcher
1000+ posts
Custom Programming Languages
What do callbacks have to do with this?
Signatures are the only place where assets links still work.
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
Because the syntax of a callback is…
import Console
fun main() {
// Create a callback and run it.
{
Console.out("Hello, world!")
}()
}
Try out Noml!
- ajskateboarder
- Scratcher
1000+ posts
Custom Programming Languages
The language probably uses braces for callbacks already, so it would hard to differentiate, to some degree What do callbacks have to do with this?
- NFlex23
- Scratcher
1000+ posts
Custom Programming Languages
So a callback is just an anonymous function? Any reason you aren't using `fn() { … }`? Because the syntax of a callback is…import Console
fun main() {
// Create a callback and run it.
{
Console.out("Hello, world!")
}()
}
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- __Falcon-Games__
- Scratcher
1000+ posts
Custom Programming Languages
Because that's weird and annoying. I also just like { … } over fn() { … }.So a callback is just an anonymous function? Any reason you aren't using `fn() { … }`? Because the syntax of a callback is…import Console
fun main() {
// Create a callback and run it.
{
Console.out("Hello, world!")
}()
}
Try out Noml!
- NFlex23
- Scratcher
1000+ posts
Custom Programming Languages
While it may be faster to type, I think your syntax may be a bit more confusing since you already have `fn x() { … }` for defining functions, and `{…}` is typically used for objects/records/arrays in most other languages. Also, how would you denote parameters in the function?Because that's weird and annoying. I also just like { … } over fn() { … }.So a callback is just an anonymous function? Any reason you aren't using `fn() { … }`? Because the syntax of a callback is…import Console
fun main() {
// Create a callback and run it.
{
Console.out("Hello, world!")
}()
}
Last edited by NFlex23 (Oct. 12, 2023 13:26:12)
Help improve the Advanced Topics (Really!)
Before you create a topic:
Always search for duplicates or other similar topics before making an umbrella topic, e.g., “The Mac Topic”.
- Is it about something you are planning on making but haven't made yet? If so, please wait to post until you have created a working prototype. This is a key factor to keeping the ATs as clean as possible.
- The ATs aren't technical support. It is perfectly valid to ask questions about things related to programming, but not issues with external websites, apps, or devices. Most sites have their own support system; try asking there!
- Is it related to something you are making in Scratch? (This includes OSes and other Scratch projects) If so, please post in Collaboration, Show and Tell, or another similar forum.
- Is your topic questionably “advanced”? Try browsing the other forums to see if your topic fits better in one of those.
- Issues with Scratch itself should be put in Bugs and Glitches.
- ajskateboarder
- Scratcher
1000+ posts
Custom Programming Languages
Wait so how would you supply arguments to the anonymous function if it's just a block? Would you do:Because that's weird and annoying. I also just like { … } over fn() { … }.So a callback is just an anonymous function? Any reason you aren't using `fn() { … }`? Because the syntax of a callback is…import Console
fun main() {
// Create a callback and run it.
{
Console.out("Hello, world!")
}()
}
((x, y){Console.out(x + y)})(12, 1)