Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

see, that was missing from the tutorial, or did I miss it? :ok and :nope - are those valid keywords or functions?


sort by: page size:

And I forgot: 3. keyword arguments to functions. :)

Having 2 to 3 keywords for the exact same purpose seems like a nightmare. Do we need `def`, `fun`, and `function`? Just pick one and only one.

On another note, the docs are not so good. They're really missing a few real life examples with unit tests.


I am wondering how to add keywords at runtime, or remove all the keywords and make them functions...

the function keyword is unnecessary - removing it makes the function creation more cross-compatible with different shells.

I miss keyword syntax. It has its warts, but I liked the clarity better than the whole funarg() list mess.

1. Yes 2. I also don't like that their naming convention doesn't reflect functionality. How would you assign carp, cluck, croak and confess functions?

I didn't know the last one. Nevertheless I find the mix of functions with no arguments, function values and optionnal parenthesis quite confusing syntax wise.

Thanks, updated the code to use keyword arguments only.

Are there any context sensitive help, tooltips, etc ?

Seeing two function definitions, my first inclination was to run them on the next two lines, via

  setup();
  draw(); 
So that was wrong.

Ok, so the functions run themselves automagically.

Guessing that there must be line and circle functions, I managed to get those running.

How do I discover new stuff?

Shift - Tab is not doing anything over function signatures(Jupyter can do that in the browser sort of ok).

What would a total newbie do next without going over to Help tab?


They're not reserved keywords. Existing/package defined min/max functions would take precedence. They have the same semantics as `append`

Thanks for pointing it out. Still, it seems highly unlikely someone would decide to use such a function declaration yet want to use the proposed syntax to pass both positional and keyword arguments.

Wirth entered the chat:

Procedures should do something. Functions should return something.

https://en.wikipedia.org/wiki/Command%E2%80%93query_separati...

By the way, I have never understood the practice of using a verb in the name of a (pure) function; naming the function after its result using a noun or adjective phrase makes much more sense.


I like it. I wasn't aware you could have function names with the same name as a keyword.

Ninja edit: appears you can't, it has to be an undefined method caught with __call(). Neat.


Isn't being able to give functions as a default keyword argument more or less obvious when functions are first-class objects instead of it being insane? It's something that I use several times in any decent sized project.

For my bot for the current Google AI challenge I use A* pathfinding and one of the keyword args is the function for getting a node's neighbours.


alternatively, they could add calling functions with keyword arguments as in python, where you'd call key_exists(needle="needle", haystack="haystack")

If it helps I'm thinking of expanding the usage of those bindings to function keyword and default arguments as well. :)

Yeah, I know that. I had about 40 tabs open with every page I could find. All I'm saying is that It takes a while to figure out stuff like:

I would like to call toLowerCase on a list of strings. How do I pass an argument to the function?

(map #(.toLowerCase %) word-list)

It's not exactly obvious without a bit of searching what # and % and . mean here.


So you _actually_ use function names as strings? That seems like a problem, and that it would need its own special editor tooling. Yikes.

Use snippets. Function? No. Defn? No. Fn. I type fn. Depending on the file you get the right thing.
next

Legal | privacy