Shape() & beginswith()


#1

i’d like to propose two syntax changes, which i wonder whether have been discussed before. i don’t really hold any realistic hope that the proposed changes will be made due to the entrenched usage of the existing syntax, nevertheless here goes…

first, the mere fact there is sizeof, which needs a preposition as suffix to distinguish it from size, is an indication that a better choice could be made. why does julia not adopt python’s shape for our current size, and then repurpose size to mean the current sizeof? that would be a lot easier to remember.

second, julia used to have beginswith, to match endswith, but 9578 changed it to startswith, which happens to match python. despite having a begin block that terminates in an end folks thought it was “inconsistent” with seekstart and start. as a native english speaker, i disagree-- to me, the opposite of start is finish, and that of begin is end. anyone else agree?


#2

:-1: to shape - size is more intuitive for me. (Also, Plots exports Shape, which may not matter, but just illustrates that shape is a word that is also really useful for actual geometry).
Agree with beginswith FWIW


#3

to finish the second thought-- how about using prefix for the current startswith and suffix for endswith? much shorter to boot.


#4

I am not a native English speaker, so I checked Google for the number of hits when searching for the exact phrases “words that begin/start/end/finish with x”. Here’s the data:

“words that start with x” - About 1.330.000 results
"words that begin with x" - About 90.000 results
"words that end with x" - About 200.000 results
"words that finish with x" - 6 results

(I only tried the letter “x”, but I suspect other letters would give similar results.)

Even though start-end might not feel like a natural pair, it seems to be the most common choice of words when people talk about what letter a word begins or finishes with.

(As to the sizeof function, it is mostly needed when doing low-level stuff, like calling C functions, or manually allocating memory. I would say it makes sense to use the same name as in C since the anyone who uses sizeof will likely know C already.)


#5

re. shape to replace size… more reason to make this change is that we already have reshape. or perhaps folks think the latter should be renamed to resize for consistency?


#6

I actually like the idea of replacing size with shape, but that’s at least partially because I’ve used numpy for a long time, and that’s what’s used there. I find it more intuitive, but I suspect that how people feel about these things depends mostly on their background.

Cheers,
Kevin