4 ms·
Today, development means more and more work with external APIs, Open Source projects, and general code written by others. A huge time waster is coming back to a
by radagaisus 15y ago
Today, development means more and more work with external APIs, Open Source projects, and general code written by others. A huge time waster is coming back to a piece of code, and finding this: `foo(bar, true, false, true)`. Now you need to go and check the documentation of whatever you're using. IDE solve this half way with auto-complete. We sometimes use ENUMS for the boolean flags, and write yelling code `foo(bar, YES, TOTALLY, DX9_D3D_HWIN_OK_BOOL_FLAG)`. (I hate your guts DirectX). But a verbose code with argument names makes it really easy to create DSLs. Ruby wins over Python here.
`some_function arg1: val1 arg2: val2` with parentheses just to solve ambiguity.
On another note, I always did not understand why there's no For..Else construct, but then I met python.
- DasIch 15y agoIf you are using Python, you can call any function with keyword arguments e.g foo(bar, something=True, whatever=False, blubb=True) even if it is defined using positional arguments like foo(bar, something, whatever, blubb)
- radagaisus 15y agoYeah, I know, but in Ruby you can drop the parentheses. And in 1.9+ instead of `:something => 'value' you can write just `something: 'value'`. Python: `make('coffee', sugar=2, with='poison')`. Ruby: `make 'coffee', 2, with: ['poison']`. I prefer Ruby's style but it's still lacking.