"Sputnik" help  
Sputnik Help
Rule Override


This demonstrates how to create a function that can replace a Sputnik core function by the same name.

Before reading this section make sure to read all User Functions and understand it.


The override rule in Sputnik allows you to replace a core function with a custom function that has the same name. By using the "o" flag or rule, you can override the default behavior of a core function and provide your own implementation.

When a core function is overridden, all calls to that function will be directed to your custom function instead. This can be useful if you want to extend the functionality of a core function or modify its behavior to better suit your needs.

It's important to exercise caution when overriding core functions because Sputnik relies on the default behavior of these functions to ensure proper execution. If a core function is replaced and Sputnik tries to call it, unexpected or undesirable behavior may occur.

The example provided demonstrates how to replace the core function Say() with a custom function. The custom function takes variable arguments using the "..." syntax and prints a custom message by joining the arguments together. When the Say() function is called, it invokes the custom function instead of the core function, resulting in the custom message being printed.

When using the override rule, it's important to ensure that your custom function provides the necessary functionality expected by the core function. This may involve replicating the behavior of the core function or providing additional features on top of it.

By using the override rule, you can tailor the behavior of core functions to better suit your requirements and extend the capabilities of Sputnik. However, it should be used with caution and careful consideration of the impact on the overall system.


User Functions
Rule Replace


Example of replacing a core function using the "o" flag/rule:

Say("Moo moo farm");

"o" Function Say("..." $args)
    println "Custom Say: " . join($args);
// Custom Say: Moo moo farm

// This forces all calls to Say() (core) function to go to your
// function instead this can prove useful if you are extending
// the functionality of a core function.
// Be careful however since Sputnik might want to call one of the
// cores and suddenly find it does not exist and behave in weird and/or
// disastrous way.

That is how to replace a core function.

Cheryl (uberfox@hotmail.com)