3

In programming, to cast (also: to typecast) means to convert an object from one type to another (see Wikipedia).

I'd like to know the correct past tense of to cast in this sense. Is it cast or casted?

I'm aware that there is already a similar question: Can “casted” be the past tense of “cast”? However, that question has only one answer mentioning this particular usage of the word, and it doesn't quote any sources.

  • Cast is pretty much always simply cast regardless of tense, the exception being casting. That said, casted has been around for a long time and wouldn't be misunderstood (though many frown upon it). See this link for some more information. – Doc Jan 17 '14 at 20:54
  • 1
    This is a special sense and a causative one at that. Zero-derived causatives are often regular, even with an irregular intransitive. Like shine, shone, shone (vi) vs shine, shined, shined (vt). So it could be either one. So the correct way to find out is to ask English-speaking programmers which one they use. More on the subject of monosyllabic t/d-final uninflected verbs here (click on -- show quoted text -- to get the context). – John Lawler Jan 17 '14 at 21:03
  • 2
    I would personally use ‘casted’ in the sense of casting someone for a play, or of putting a cast on someone (“They casted him for the role” and “Her leg was casted”), but when coding, I would say, for example, “I cast the float as a string”, and “The float was recast as a string”. – Janus Bahs Jacquet Jan 17 '14 at 21:08
  • @JanusBahsJacquet Interesting. I can’t say casted at all. – tchrist Jan 17 '14 at 21:17
  • I'm not sure I'd ever have used *casted* myself - it has a distinctly "dated" flavour to me, bordering on the archaic. But it's interesting that this is one of relatively few verbs bucking what I see as a slow but steady drift towards regularising the conjugation. – FumbleFingers Jan 17 '14 at 22:09
  • I'd use past tense cast for fishing but casted for plays/programmes. For programs, I'll defer to Janus. – Edwin Ashworth Jan 17 '14 at 23:18
  • principal parts: cast, cast, cast. No exceptions. – Lambie Nov 19 '21 at 23:00

5 Answers5

3

Oxford Dictionaries rather tersely states that past and past participle of cast is cast. So:

As a novice programmer, I had blithely cast opaque pointers to pointers of unsigned char to access the raw bytes contained therein.

Gnawme
  • 40,887
  • John Lawler is less terse (and, I'd say, more accurate here). – Edwin Ashworth Jan 17 '14 at 23:20
  • @EdwinAshworth Perhaps, although I'd dispute his assertion that "the correct way to find out is to ask English-speaking programmers which one they use." The road to grammar hell is paved with English-speaking programmers... (And the intersection of "people who care about speaking and writing English well" and "programmers" is likely a rather small set.) – Gnawme Jan 17 '14 at 23:32
  • On the other hand, it's specialists who are best at defining terms and usages in their field, in spite of the fact that there will be disagreements and sloppiness even amongst them. Here, there are the already existing versions cast and casted for them to choose between; I can't see that one is inherently 'better' than the other. It seems OD doesn't mention domains (eg fishing, dramas ...). Preferences are often domain-related. – Edwin Ashworth Jan 18 '14 at 10:44
  • All answers have made valid points. Personally, I've chosen to go with "cast". I'll accept this answer because it cites an authoritative source, terse though it may be. – Daniel Wolf Jan 18 '14 at 20:36
  • OED will almost certainly also include 'casted', but perhaps with a usage note. This thread states 'Casted is an old form ... In current usage, however, casted is gaining ground, especially where cast means either (1) to assemble actors for a performance, or (2) to throw out bait and/or a lure on a fishing line. (Both these senses have extended metaphorical uses where casted is likewise used at least some of the time). Many people object to casted, but that doesn’t change the fact that it is catching on and not likely to go away soon.' – Edwin Ashworth Jan 19 '14 at 11:23
1

CAST is a standard keyword in SQL languages (standard in ANSI SQL since SQL-92, and in other varieties since earlier than that). As a database professional who follows the industry, I see both forms of the past tense being used frequently in the major industry publications and blogs.

Programmers are generally comfortable with this kind of lexical ambiguity. Programming languages themselves often have multiple words to accomplish the same operation. For example, in Microsoft's T-SQL there is a CONVERT keyword that performs the same function as the CAST keyword, but with a different syntax.

Any true-blooded programmer prefers CAST to CONVERT, though, for its brevity and efficiency. Fewer characters counts for points in code golf, and often for better performance in the real world.

Therefore, give the edge to cast over casted, for its equally admirable brevity.

In programmers' terms, you'll be reducing your technical debt.

Jonathan Van Matre
  • 1,122
  • 7
  • 11
  • 1 for useful, relevant information. I disagree, however, that this is a good reason to prefer cast when speaking English rather than programming.
  • – Tim Lymington Jan 17 '14 at 23:42
  • When speaking English in general, I agree. When speaking English about things other than programming with programmers, I also agree. When speaking English to a philosopher about philosophy, "valid" means something different than it does in common usage. Likewise, when speaking English to a programmer about programming, there are domain-specific contingencies that carry some weight. – Jonathan Van Matre Jan 17 '14 at 23:53
  • First, cast is used in programming in other contexts, and SQL is not the origin of it in this sense, so SQL isn't authoritative. Second, I would certainly write CONVERTed in talking about having used that operation, and I am far from alone in that. Third, true-blooded programmers prefer CAST because it's the standard, more than brevity. Fourth, CONVERT is more flexible, so there are times when it is worth using. – Jon Hanna Jan 18 '14 at 00:42