Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

enforce lit-word! param

To enforce passing a lit-word! param, you need to make the param a get-word!, so it isn't evaluated when the func is called. This won't work if you're dynamically creating the param of course.

incr: func [
    {Increment a value by 1.}
    :word [lit-word!]
    /by {Change by this amount}     ; /skip ?
        value
][
    set word add get word any [value 1]
]


;>> a: 0
;== 0
;>> incr a
;** Script Error: incr expected word argument of type: ;lit-word
;** Near: incr a
;>> incr 'a
;== 1

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS