49

The languages in the Visual Basic family do exactly this. This includes VBScript, VBA, Visual Basic and earlier. I believe these inherit the "feature" from QBASIC. For example Public Function AddTwo(something as Integer) AddTwo = something + 2 End Function


45

Pascal does this, I don't know of others. Don't know if the practice move forward with other Wirth languages.


27

Fortran, for sure: PROGRAM TRIANG WRITE(UNIT=*,FMT=*)'Enter lengths of three sides:' READ(UNIT=*,FMT=*) SIDEA, SIDEB, SIDEC WRITE(UNIT=*,FMT=*)'Area is ', AREA3(SIDEA,SIDEB,SIDEC) END FUNCTION AREA3(A, B, C) *Computes the area of a triangle from lengths of sides S = (A + B + C)/2.0 AREA3 = SQRT(S * (S-...


21

The earliest such languages I can find are FORTRAN II and ALGOL 58, both published in the same year 1958; though the original FORTRAN (1956) can arguably also be included. For FORTRAN, the first page of the manual chapter covering functions contains this example (p. 27): FUNCTION AVRG (ALIST, N) DIMENSION ALIST (500) SUM = ALIST (1) DO 10 I=2, N SUM = SUM + ...


17

TL;DR: I'd say, most likely it is PASCAL you remember, as it was rather popular in the early 80s, used in University courses all thru the 80s way into the 90s and still had some fellowship there after, most notably Delphi. Some History The basic idea is that the function name is not only already reserved, so no need to come up with anything different, and ...


12

The phrase In some cases a sufficiently smart compiler could figure out some of these precedence relationships. was used in the 1979 book: https://www.sciencedirect.com/science/article/pii/B9780120441204500088 Chapter 3 - SIMSCRIPT: PAST, PRESENT, AND SOME THOUGHTS ABOUT THE FUTURE HARRY M.MARKOWITZ Indicating that it predated Steele, and also that it ...


11

Fortran has used this syntax, from the earliest version which had functions at all right up to Fortran 2008 and beyond. However Fortran 2008 has an (even more confusing?) option where you can declare a different variable name that is used to return a function value! For example function xyz(argument) result(answer) ... answer = 42 ... end function xyz ...


8

Algol 60 for one. Here's the relevant words from the Revised Report on the Algorithmic Language Algol 60. 5.4.4. Values of function designators. For a procedure declaration to define the value of a function designator there must, within the procedure declaration body, occur one or more explicit assignment statements with the procedure identifier in a left ...


8

The Evolution of Lisp, an outline of the history, traces the phrase back to 1984. See page 42. https://www.scribd.com/document/62651058/The-Evolution-of-Lisp


8

The phrase any sufficiently advanced/smart/etc X in a technology context stems from (in other words, is a snowclone of) the Arthur C. Clarke's quote “Any sufficiently advanced technology is indistinguishable from magic” (1962 1973).


6

The BASIC language did not have the notion of variable scopes. All variables were statically allocated and globally accessible.


5

BASIC is another language with functions where some dialects used assignment to the function name to provide the return value. The earliest dialects were similar to Fortran single-line functions: DEF FND(x) = x*x But later dialects allowed more complex variants, similar to Fortran multi-line functions: DEF FNPeekWord& (A&) FNPeekWord& = PEEK(A&...


5

In C, if a variable has "static" in front of it, it is private to the code module. If someone decides to stick it in a header file, then every source file that #includes that header file will have their own private copy.


5

I believe that SNOBOL4 did this. http://berstis.com/greenbook.pdf The following is an example of the definition and use of a function to compute factorials of numbers: DEFINE('FACT(N)') :(SKIPFCN) * Set value to 1 FACT FACT = 1 * Return 1 if N<2 * Return N*((N-1)!) with recursive call FACT = GT(N,1) FACT(N - 1) * N :(RETURN) SKIPFCN ...


5

MATLAB / Octave also does this. It is from 1984; so not as old as some of the others. It was probably imitating Fortran, since it was orginally concieved as a high-level tool. On top of the Fortran libraries like Linpack and Eispack.


4

Verilog (1995/2001) also returns by assignment to implicit variable. SystemVerilog added the "return" statement but the classic assignment is still available.


2

(I guess this isn't really retrocomputing, and more general programming languages theory ...) "Private" in OOP is tied to a particular object, and non-OOP languages usually don't have objects. If you allow other constructs: Module systems in nearly all languages have a concept of "exported" vs. "non-exported" ("private"...


1

Haskell (from 1990) does this as well: doubleMe x = x + x defines a function doubleMe of one parameter x and assigns the function body x+x to it, see the great Learn You A Haskell For Great Good


Only top voted, non community-wiki answers of a minimum length are eligible