Scarp v0.0.5-alpha.3 — प्रकाशित compiler और नई CLI

प्रकाशित: 2 नवंबर 2026, 19:41 IST। आधिकारिक prerelease और निश्चित compiler source commit 7715c28df09c7703b39e14fddb963275b25df476।

नई Scarp-first CLI

प्रकाशित alpha.3 में exec, verify, inspect tokens, inspect ast, inspect modules, guide, version और offline diagnose --json commands हैं। पुराने run, check, tokens और modules commands अभी पुराने scripts और extensions के लिए उपलब्ध हैं।

महत्वपूर्ण अंतर: scarp verify source और module types की static जाँच करता है, लेकिन सामान्य runtime statements नहीं चलाता। पुराना scarp check चुने हुए runtime paths को चुपचाप execute करता है। inspect ast केवल parser का मानव-पठनीय development output है, स्थिर JSON AST या पूर्ण type checker नहीं। अलग inspect modules --json versioned metadata देता है। कोई भी command .srp से native executable या package manager नहीं बनाता।

Alpha.3 executable के साथ examples वाले folder से commands चलाएँ:

scarp version
scarp diagnose --json
scarp exec text_construction.srp
scarp verify text_construction.srp
scarp inspect tokens text_construction.srp
scarp inspect ast text_construction.srp
scarp inspect modules --json collection_module.srp
scarp explain E0015

diagnose --json offline environment/capability report है, health diagnosis नहीं। सफल inspect ast के debug output को स्थायी machine protocol की तरह parse नहीं करना चाहिए।

प्रकाशित compiler के चार पूरे प्रोग्राम

नीचे टैग में उपलब्ध examples के पूरे .srp, imported modules और stdout हैं। English/Hindi के source/output blocks को सटीक upstream Git blobs से जाँचा जाता है। अलग CI job उसी published compiler को build करके verify और exec के output की byte-for-byte तुलना करती है।

1. Unicode text निर्माण

मुख्य फ़ाइल: text_construction.srp

bind greeting: string = text_concat("Hello, ", "🌍");
bind planet = text_slice(greeting, 7, 1);
print(greeting);
print(text_repeat(planet, 3));
print(text_len(greeting), text_bytes(greeting));

प्रकाशित stdout:

Hello, 🌍
🌍🌍🌍
8 11

text_concat strings जोड़ता है, text_slice Unicode scalar index पर काम करता है और text_repeat text दोहराता है। 🌍 एक scalar लेकिन चार UTF-8 bytes है। Text allocation सीमित है; strings के लिए + concatenation मान्य नहीं है।

2. Contracts के साथ float refinement

मुख्य फ़ाइल: float_refinement.srp

// Newton refinement uses float values and an integer iteration count.
pure funcra root(value: float, steps: integer = 6) -> float
    needs value > 0.0;
    needs steps >= 0;
    ensures result > 0.0;
{
    var estimate = 1.0;
    repeat steps as iteration {
        estimate = (estimate + value / estimate) / 2.0;
    }
    return estimate;
}

bind sqrt2 = root(2.0);
print("sqrt2 checked", sqrt2 > 1.414 and sqrt2 < 1.415);
print("sqrt9", root(9.0));

प्रकाशित stdout:

sqrt2 checked true
sqrt9 3.0

यह उदाहरण typed pure funcra, preconditions, postcondition और bounded repeat के साथ square-root approximation देता है। यह arbitrary-precision math library नहीं है।

3. Modules के बीच typed integer collection

आयात की गई फ़ाइल: modules/integer_series.srp

pub bind low_bits = 0b1111;

pub pure funcra sequence(count: integer, start: integer = 0) -> integers
needs count >= 0;
ensures ints_len(result) == count;
{
    return ints_range(start, count, 1);
}

pub pure funcra spread(values: integers) -> float
needs ints_len(values) > 0;
{
    return stddev(ints_to_vector(values));
}

मुख्य फ़ाइल: collection_module.srp

import "modules/integer_series.srp" as series;
bind values = series.sequence(2, start: -1);
print(values, series.spread(values), series.low_bits & 0x3);

प्रकाशित stdout:

[integer: -1, 0] 0.5 3

Imported module integers result, typed default argument, ints_range, stddev और bitwise mask उपयोग करता है। सभी files के relative paths सुरक्षित रखें; private module declarations उपलब्ध नहीं हो जाते।

4. स्पष्ट coefficient fitting

मुख्य फ़ाइल: coefficient_fit.srp

// Fit y = coefficient * x using an explicitly written squared-error gradient.
pure funcra loss(inputs: vector, targets: vector, coefficient: float) -> float
    needs len(inputs) > 0;
    needs len(inputs) == len(targets);
{
    return mse(scale(inputs, coefficient), targets);
}

bind inputs = [1.0, 2.0, 3.0];
bind targets = [2.0, 4.0, 6.0];
var coefficient = 0.0;
repeat 40 as iteration {
    bind residuals = add(scale(inputs, coefficient), scale(targets, -1.0));
    bind gradient = 2.0 * dot(inputs, residuals) / 3.0;
    coefficient -= 0.05 * gradient;
}
print(coefficient > 1.999999999 and coefficient < 2.000000001);
print(loss(coefficient: coefficient, targets: targets, inputs: inputs) < 1e-18);

प्रकाशित stdout:

true
true

इस numerical example में gradient updates उपयोगकर्ता के code में स्पष्ट लिखे हैं। यह built-in automatic differentiation या पूर्ण AI training framework नहीं है।

Structured diagnostic (schema version 1)

इस प्रकाशित उदाहरण में type mismatch की वजह से जानबूझकर E0015 त्रुटि आती है। पूरा source:

// This sample intentionally reports E0015.
bind count: integer = "two";

प्रकाशित JSON diagnostic snapshot:

{"schema_version":1,"severity":"error","code":"E0015","message":"expected integer, found string","span_encoding":"utf-8-bytes","column_encoding":"unicode-scalar","position_base":1,"primary":{"path":"type_error.srp","span":[66,71],"start":{"line":2,"column":23},"end":{"line":2,"column":28}},"related":[{"message":"the binding's type is declared here","location":{"path":"type_error.srp","span":[56,63],"start":{"line":2,"column":13},"end":{"line":2,"column":20}}}],"help":"keep primitive types consistent; numeric operands must share a numeric kind, logic requires booleans"}

--diagnostic-format=json से असफल compilation के diagnostics machine-readable होते हैं; सफल AST का JSON नहीं बनता। Source spans UTF-8 byte offsets हैं और line/column Unicode scalar characters पर आधारित हैं। CI प्रकाशित snapshot के schema तथा E0015 की जाँच करती है; program stdout खाली रहना चाहिए।

सही स्थापना और परीक्षण

Alpha.3 release assets से Windows x64, Linux x64 या macOS ARM64 archive चुनें। प्रकाशित SHA-256 checksum मिलाएँ और scarp version या scarp --version से executable की पहचान जाँचें।

पुराना upgrade readiness test केवल 11 alpha.1 fixtures को alpha.2 पर चलाने का प्रमाण है; इससे हर project के alpha.3 पर compatible होने की गारंटी नहीं मिलती। यह अभी stable language release नहीं है।

दस्तावेज़ खोजें