<commit_before>REBOL [
    System: "REBOL [R3] Language Interpreter and Run-time Environment"
    Title: "REBOL 3 Boot Base: Function Constructors"
    Rights: {
        Copyright 2012 REBOL Technologies
        REBOL is a trademark of REBOL Technologies
    }
    License: {
        Licensed under the Apache License, Version 2.0
        See: http://www.apache.org/licenses/LICENSE-2.0
    }
    Note: {
        This code is evaluated just after actions, natives, sysobj, and other lower
        levels definitions. This file intializes a minimal working environment
        that is used for the rest of the boot.
    }
]

assert: func [
    {Ensure conditions are conditionally true if hooked by debugging}

    return: []
    conditions [block!]
        {Block of conditions to evaluate and test for logical truth}
][
    ; ASSERT has no default implementation, but can be HIJACKed by a debug
    ; mode with a custom validation or output routine.
    ;
    ; !!! R3-Alpha and Rebol2 did not distinguish ASSERT and VERIFY, since
    ; there was no idea of a "debug mode"
]


maybe: enfix func [
    "Set word or path to a default value if that value is a value"

    return: [<opt> any-value!]
    'target [set-word! set-path!]
        "The word to which might be set"
    optional [<opt> any-value!]
        "Value to assign only if it is not null"

    <local> gotten
][
    if semiquoted? 'optional [
        ;
        ; While DEFAULT requires a BLOCK!, MAYBE does not.  Catch mistakes
        ; such as `x: maybe [...]`
        ;
        fail 'optional [
            "Literal" type of :optional "used w/MAYBE, use () if intentional"
        ]
    ]

    case [
        set-word? target [
            if null? :optional [return get target]
            set target :optional
        ]

        set-path? target [
            ; If a SET-PATH!, it may contain a GROUP!.  SET/GET don't accept
            ; that due to potential side-effects, so use REDUCE.  See also:
            ;
            ; https://github.com/rebol/rebol-issues/issues/2275
            ;
            if null? :optional [return do compose [(as get-path! target)]]
            do compose [(target) lit ((:optional))]
        ]
    ]
]

<commit_msg>Do not splice when using COMPOSE in MAYBE<commit_after>REBOL [
    System: "REBOL [R3] Language Interpreter and Run-time Environment"
    Title: "REBOL 3 Boot Base: Function Constructors"
    Rights: {
        Copyright 2012 REBOL Technologies
        REBOL is a trademark of REBOL Technologies
    }
    License: {
        Licensed under the Apache License, Version 2.0
        See: http://www.apache.org/licenses/LICENSE-2.0
    }
    Note: {
        This code is evaluated just after actions, natives, sysobj, and other lower
        levels definitions. This file intializes a minimal working environment
        that is used for the rest of the boot.
    }
]

assert: func [
    {Ensure conditions are conditionally true if hooked by debugging}

    return: []
    conditions [block!]
        {Block of conditions to evaluate and test for logical truth}
][
    ; ASSERT has no default implementation, but can be HIJACKed by a debug
    ; mode with a custom validation or output routine.
    ;
    ; !!! R3-Alpha and Rebol2 did not distinguish ASSERT and VERIFY, since
    ; there was no idea of a "debug mode"
]


maybe: enfix func [
    "Set word or path to a default value if that value is a value"

    return: [<opt> any-value!]
    'target [set-word! set-path!]
        "The word to which might be set"
    optional [<opt> any-value!]
        "Value to assign only if it is not null"

    <local> gotten
][
    if semiquoted? 'optional [
        ;
        ; While DEFAULT requires a BLOCK!, MAYBE does not.  Catch mistakes
        ; such as `x: maybe [...]`
        ;
        fail 'optional [
            "Literal" type of :optional "used w/MAYBE, use () if intentional"
        ]
    ]

    case [
        set-word? target [
            if null? :optional [return get target]
            set target :optional
        ]

        set-path? target [
            ; If a SET-PATH!, it may contain a GROUP!.  SET/GET don't accept
            ; that due to potential side-effects, so use REDUCE.  See also:
            ;
            ; https://github.com/rebol/rebol-issues/issues/2275
            ;
            if null? :optional [return do compose [(as get-path! target)]]
            do compose [(target) lit (:optional)]
        ]
    ]
]


{'fraction_non_alphanumeric': 0.08598298253470667, 'fraction_numerical': 0.007165248544558889, 'mean_word_length': 2.0595890410958906, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5072032', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1254, 'n_words': 513}