Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the technical definition for "routine"?

I'm studying lisp language (to do lisp routines) and in a general context i know what's a routine, but in a technical context i can talk about it, because i'm starting to learn routines now. So, what's the real definition of routine? (i've already "googled" this but didn't find anything)

like image 373
FERNANDO MESQUITA Avatar asked Jul 30 '11 20:07

FERNANDO MESQUITA


People also ask

Whats the definition for routine?

1 : a usual order and way of doing something Taking a shower is part of my morning routine. 2 : a series of things that are repeated as part of a performance a dance routine. routine. adjective. Kids Definition of routine (Entry 2 of 2)

What is routine and example?

First, let's define what routine means: A routine is a sequence of actions that you do repeatedly. Brushing your teeth nightly and getting ready for bed is a routine. Waking up at 6:00 AM and exercising every morning is a routine.

What is routine in memory management?

What is Routine in OS? In computer programming, a routine is a sequence of code that is intended to be called and used repeatedly during the execution of a program. It can range from a subroutine, co-routine to a function. This makes the program shorter and easier to write and read when necessary.

Is a routine the same as a function?

A procedure is a routine that can accept arguments but does not return any values. A function is a routine that can accept arguments and returns one or more values.


2 Answers

The term routine derives from subroutine, which is a more common term in languages like BASIC where one actually creates SUBroutines. (BASIC actually had a difference between a SUBroutine and a FUNCTION, but nevertheless...)

From the Wikipedia entry:

In computer science, a subroutine (also called procedure, function, routine, method, or subprogram) is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code.

As the name "subprogram" suggests, a subroutine behaves in much the same way as a computer program that is used as one step in a larger program or another subprogram. A subroutine is often coded so that it can be started ("called") several times and/or from several places during a single execution of the program, including from other subroutines, and then branch back (return) to the next instruction after the "call" once the subroutine's task is done.

Different languages/environments/eras have different ecosystems and thus different terms to describe the same general concept. I generally only use the term function (or method in an "OOP" environment) these days.

Happy coding.


For fun I have Community Wiki'ed. The list below is hopefully to cover which term(s) is (are) "correct" (widely accepted) to use in a given language to mean routine. Informally routine is used in context of all the languages below so it should be omitted unless it is the defacto term used. Feel free to add, correct, and annotate as appropriate.

  • C - function
  • Java - method. While function is also often used, the term function does not appear in the Java Language Specification.
  • C# - method and function. In the specification, functions refer to function-objects and anonymous functions. They are not the same as methods, which are members of types (classes or structures). Also consider delegates.
  • JavaScript - function or method. Methods are functions accessed via a property of an object.
  • Haskell - function. This is the accepted terminology.
  • Scala - function or method. Method if def member of type, functions are first-class values.
  • BASIC - function or subroutine. Subroutines do not return values. Supports call-by-reference.
  • FORTRAN - function or subroutine. Subroutines do not return values. Supports call-by-reference.
  • LISP - function. DEFUN -> DEfineFUNction, all forms are valid expressions. Also consider macros, which are not themselves functions but are arguably routines.
  • VHDL - subprograms: functions and procedures. Procedures have no return value.
  • SmallTalk - method
  • Python - method
  • Ruby - method (often interchanged with function? lambdas/Procs may be considered different?)
  • Perl - function and subroutine. There is only one form to declare a function/SUBroutine so there is no distinction w.r.t. return values. Using method (for object-bound functions) seems less prevalent than in other languages.
  • Pascal - procedures and functions
  • Ada - procedures and functions
like image 102
11 revs, 3 users 94%user166390 Avatar answered Nov 26 '22 06:11

11 revs, 3 users 94%user166390


You can't find a technical definition because there isn't a technical definition specific to lisp. A 'routine', outside of vaudeville, is just another name for a function. While it's been many years since I programmed in Lisp full-time, no one ever used that term in any formal way, or even used it commonly. We talked about 'functions', 'macros', and 'forms.' If someone said, 'oh, there's a routine to calculate how many apples in a pie' it was perfectly informal.

like image 26
bmargulies Avatar answered Nov 26 '22 04:11

bmargulies