gregtour / duck-lang

The Duck Programming Language
http://www.ducklang.org
109 stars 13 forks source link

Proposal to change syntax #21

Closed gregtour closed 9 years ago

gregtour commented 9 years ago

The use of end as a keyword in both functions and conditional statements is confusing. Therefore, I propose that the keyword to end a conditional statement (if or else-if) should be changed to endif.

See the following code as an example of the potential confusion.

function ReturnLessThan2(value)
    if value < 2 then
        return true
    else
        return false
    end
end

Although the two corresponding block-level statements, function and if, are different, they have the same terminating keyword.

With this proposed change the example would instead look like this.

function ReturnLessThan2(value)
    if value < 2 then
        return true
    else
        return false
    endif
end

Additionally, the syntax for functions should be changed to be both more concise and more transparent, so the symbol function will be changed to func.

With these changes, the example would become:

func ReturnLessThan2(value)
    if value < 2 then
        return true
    else
        return false
    endif
end
sh19910711 commented 9 years ago

Looks good, and +1 to change function to func, but I don't feel the end func seems better than the current style :hand:

WebFreak001 commented 9 years ago

If it would be end func then endif should be end if aswell or the other way around

gregtour commented 9 years ago

Fair enough, I changed "end func" back to "end."