LESSON 41 OF 52 · CHAPTER 05

Exported Signatures

Typed public constants, a pure function and its default argument

ORIGINAL SOURCE

05-exported-signatures.srp

pub bind base: integer = 6;
pub bind answer: integer = base * 7;
pure funcra echo(value: integer = answer) -> integer {
    return value;
}
print(echo());
EXPECTED OUTPUT

stdout

Verified
42

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

Typed public constants, a pure function and its default argument

Expected behavior

42

Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.

सार्वजनिक सिग्नेचर देखना

pub bind base: integer = 6; तथा pub bind answer: integer = base * 7; सार्वजनिक typed constants हैं। pure funcra echo(value: integer = answer) का डिफ़ॉल्ट आर्गुमेंट 42 है। प्रोग्राम चलाने से 42 छपता है।

कमांड से जाँच:

scarp inspect modules --json examples/05-modules/05-exported-signatures.srp
scarp exec examples/05-modules/05-exported-signatures.srp

पहला कमांड मॉड्यूल और फ़ंक्शन की जानकारी देता है; यह प्रोग्राम नहीं चलाता। दूसरे का आउटपुट 42 है। JSON inspection को Scarp में सामान्य JSON लाइब्रेरी न समझें। विस्तृत CLI गाइड पढ़ें।

अभ्यास: echo() बिना कोई argument देने पर 42 कैसे लौटाता है?

Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.

TRY IT LOCALLY

Verify, then execute

Use the pinned compiler from the course root. Keep any imported _support files next to the source.

scarp verify examples/05-modules/05-exported-signatures.srp scarp exec examples/05-modules/05-exported-signatures.srp

The website does not run code. Read the CLI guide ↗

CHAPTER 05 · LAST LESSON

Ready for your next step? · आगे क्या सीखें?

This is the final example in this chapter. Try its verified coding lab before moving on. Your lesson progress changes only when you mark a lesson complete.

Pinned compiler: Scarp v0.0.6-alpha.3 · ceff07d9014f. No simulated output.