Search This Blog

Saturday, November 18, 2023

John Cleese

From Wikipedia, the free encyclopedia
 
John Cleese
Cleese smiling
Cleese in 2023
Born
John Marwood Cleese

27 October 1939 (age 84)
Alma materDowning College, Cambridge
Occupation(s)Actor, comedian, screenwriter, producer
Years active1961–present
Spouses

(m. 1968; div. 1978)

(m. 1981; div. 1990)

(m. 1992; div. 2008)

Jennifer Wade
(m. 2012)
Children2
Websitejohncleese.com

John Marwood Cleese (/klz/ KLEEZ; born 27 October 1939) is an English actor, comedian, screenwriter, and producer. Emerging from the Cambridge Footlights in the 1960s, he first achieved success at the Edinburgh Festival Fringe and as a scriptwriter and performer on The Frost Report. In the late 1960s, he cofounded Monty Python, the comedy troupe responsible for the sketch show Monty Python's Flying Circus. Along with his Python costars Terry Gilliam, Eric Idle, Terry Jones, Michael Palin, and Graham Chapman, Cleese starred in Monty Python films, which include Monty Python and the Holy Grail (1975), Life of Brian (1979), and The Meaning of Life (1983).

In the mid-1970s, Cleese and first wife Connie Booth cowrote the sitcom Fawlty Towers, in which he starred as hotel owner Basil Fawlty, for which he won the 1980 British Academy Television Award for Best Entertainment Performance. In 2000, the show topped the British Film Institute's list of the 100 Greatest British Television Programmes, and in a 2001 Channel 4 poll, Basil was ranked second on its list of the 100 Greatest TV Characters.

Cleese costarred with Kevin Kline, Jamie Lee Curtis, and Michael Palin in A Fish Called Wanda (1988) and Fierce Creatures (1997), both of which he also wrote. For A Fish Called Wanda, he received Academy Award, BAFTA Award, and Golden Globe Award nominations. He has also starred in Time Bandits (1981), Clockwise (1986), and Rat Race (2001) and acted in Silverado (1985), Mary Shelley's Frankenstein (1994), two James Bond films (as R and Q), two Harry Potter films (as Nearly Headless Nick), and the last three Shrek films. He received a Primetime Emmy Award for Outstanding Guest Actor in a Comedy Series for Cheers (1987) and was nominated for 3rd Rock from the Sun (1998) and Will & Grace (2004).

Cleese has specialised in political and religious satire, black comedy, sketch comedy, and surreal humour. He was ranked the second best comedian ever in a 2005 Channel 4 poll of fellow comedians. He cofounded Video Arts, a production company making entertaining training films as well as The Secret Policeman's Ball benefit shows to raise funds for the human rights organization Amnesty International. Formerly a staunch supporter of the Liberal Democrats, in 1999, he turned down an offer from the party to nominate him for a life peerage. In 2023, he began presenting a show on GB News.

Early life and education

Cleese was born in Weston-super-Mare, Somerset, England, the only child of Reginald Francis Cleese (1893–1972), an insurance salesman, and his wife Muriel Evelyn (née Cross, 1899–2000), the daughter of an auctioneer. His family's surname was originally Cheese, but his father had thought it was embarrassing and used the name Cleese when he enlisted in the Army during the First World War; he changed it officially by deed poll in 1923. As a child, Cleese supported Bristol City and Somerset County Cricket Club. Cleese was educated at St Peter's Preparatory School (paid for by money his mother inherited), where he received a prize for English and did well at cricket and boxing. When he was 13, he was awarded an exhibition at Clifton College, an English public school in Bristol. He was already more than 6 feet (1.83 m) tall by then.

The biggest influence was The Goon Show. Kids were devoted to it. It was written by Spike Milligan. It also had Peter Sellers in it, who of course is the greatest voice man of all time. In the morning, we'd be at school and we'd discuss the whole thing and rehash the jokes and talk about it. We were obsessed with it.

—Cleese on his greatest comedic influence growing up, 1950s BBC Radio comedy The Goon Show.

Cleese allegedly defaced the school grounds, as a prank, by painting footprints to suggest that the statue of Field Marshal Earl Haig had got down from his plinth and gone to the toilet. Cleese played cricket in the First XI and did well academically, passing eight O-Levels and three A-Levels in mathematics, physics and chemistry. In his autobiography So, Anyway, he says that discovering, aged 17, he had not been made a house prefect by his housemaster affected his outlook: "It was not fair and therefore it was unworthy of my respect... I believe that this moment changed my perspective on the world."

Cleese could not go straight to Cambridge, as the ending of National Service meant there were twice the usual number of applicants for places, so he returned to his prep school for two years to teach science, English, geography, history, and Latin (he drew on his Latin teaching experience later for a scene in Life of Brian, in which he corrects Brian's badly written Latin graffiti). He then took up a place he had won at Downing College, Cambridge, to read law. He also joined the Cambridge Footlights. He recalled that he went to the Cambridge Guildhall, where each university society had a stall, and went up to the Footlights stall, where he was asked if he could sing or dance. He replied "no" as he was not allowed to sing at his school because he was so bad, and if there was anything worse than his singing, it was his dancing. He was then asked "Well, what do you do?" to which he replied, "I make people laugh."

At the Footlights theatrical club, Cleese spent a lot of time with Tim Brooke-Taylor and Bill Oddie and met his future writing partner Graham Chapman. Cleese wrote extra material for the 1961 Footlights Revue I Thought I Saw It Move, and was registrar for the Footlights Club during 1962. He was also in the cast of the 1962 Footlights Revue Double Take! Cleese graduated from Cambridge in 1963 with an upper second. Despite his successes on The Frost Report, his father sent him cuttings from The Daily Telegraph offering management jobs in places like Marks & Spencer.

Career

1963–1968: Pre-Python

Cleese was a scriptwriter, as well as a cast member, for the 1963 Footlights Revue A Clump of Plinths. The revue was so successful at the Edinburgh Festival Fringe that it was renamed Cambridge Circus and taken to the West End in London and then on a tour of New Zealand and Broadway, with the cast also appearing in some of the revue's sketches on The Ed Sullivan Show in October 1964.

After Cambridge Circus, Cleese briefly stayed in America, performing on and off-Broadway. While performing in the musical Half a Sixpence, Cleese met future Python Terry Gilliam as well as American actress Connie Booth, whom he married on 20 February 1968. At their wedding at a Unitarian Church in Manhattan, the couple attempted to ensure an absence of any theistic language. "The only moment of disappointment," Cleese recalled, "came at the very end of the service when I discovered that I'd failed to excise one particular mention of the word 'God.'" Later, Booth became a writing partner. He was soon offered work as a writer with BBC Radio, where he worked on several programmes, most notably as a sketch writer for The Dick Emery Show. The success of the Footlights Revue led to the recording of a short series of half-hour radio programmes, called I'm Sorry, I'll Read That Again, which were so popular that the BBC commissioned a regular series with the same title that ran from 1965 to 1974. Cleese returned to Britain and joined the cast. In many episodes, he is credited as "John Otto Cleese" (according to Jem Roberts, this may have been due to the embarrassment of his actual middle name Marwood).

Also in 1965, Cleese and Chapman began writing on The Frost Report. The writing staff chosen for The Frost Report consisted of a number of writers and performers who went on to make names for themselves in comedy. They included co-performers from I'm Sorry, I'll Read That Again and future Goodies Bill Oddie and Tim Brooke-Taylor, and also Frank Muir, Barry Cryer, Marty Feldman, Ronnie Barker, Ronnie Corbett, Dick Vosburgh and future Python members Eric Idle, Terry Jones, and Michael Palin. While working on The Frost Report, the future Pythons developed the writing styles that would make their collaboration significant. Cleese's and Chapman's sketches often involved authority figures, some of whom were performed by Cleese, while Jones and Palin were both infatuated with filmed scenes that opened with idyllic countryside panoramas. Idle was one of those charged with writing David Frost's monologue. During this period Cleese met and befriended influential British comedian Peter Cook, eventually collaborating with Cook on several projects and forming a close friendship that lasted until Cook's death in 1995.

It was as a performer on The Frost Report that Cleese achieved his breakthrough on British television as a comedy actor, appearing as the tall, upper class patrician figure in the classic "Class" sketch (screened on 7 April 1966), contrasting comically in a line-up with the shorter, middle class Ronnie Barker and the even shorter, working class Ronnie Corbett. The British Film Institute commented, "Its twinning of height and social position, combined with a minimal script, created a classic TV moment." This series was so popular that in 1966 Cleese and Chapman were invited to work as writers and performers with Brooke-Taylor and Feldman on At Last the 1948 Show, during which time the Four Yorkshiremen sketch was written by all four writers/performers (the Four Yorkshiremen sketch is now better known as a Monty Python sketch).

Cleese and Chapman also wrote episodes for the first series of Doctor in the House (and later Cleese wrote six episodes of Doctor at Large on his own in 1971). These series were successful, and in 1969 Cleese and Chapman were offered their very own series. However, owing to Chapman's alcoholism, Cleese found himself bearing an increasing workload in the partnership and was, therefore, unenthusiastic about doing a series with just the two of them. He had found working with Palin on The Frost Report an enjoyable experience and invited him to join the series. Palin had previously been working on Do Not Adjust Your Set with Idle and Jones, with Terry Gilliam creating the animations. The four of them had, on the back of the success of Do Not Adjust Your Set, been offered a series for Thames Television, which they were waiting to begin when Cleese's offer arrived. Palin agreed to work with Cleese and Chapman in the meantime, bringing with him Gilliam, Jones, and Idle.

1969–1983: Monty Python

Monty Python's Flying Circus ran for four series from October 1969 to December 1974 on BBC Television, though Cleese quit the show after the third. Cleese's two primary characterisations were as a sophisticate and a loony. He portrayed the former as a series of announcers, TV show hosts, and government officials (for example, "The Ministry of Silly Walks"). The latter is perhaps best represented in the "Cheese Shop" and by Cleese's Mr Praline character, the man with a dead Norwegian Blue parrot and a menagerie of other animals all named "Eric". He was also known for his working class "Sergeant Major" character, who worked as a Police Sergeant, Roman Centurion, etc. Cleese also appeared during some abrupt scene changes as a radio commentator (usually outfitted in a dinner suit) where, in a rather pompous manner, he would make the formal and determined announcement "And now for something completely different", which later became the title of the first Monty Python film.

Partnership with Graham Chapman

He was the greatest sounding board I've ever had. If Graham thought something was funny, then it almost certainly was funny. You cannot believe how invaluable that is.

— Cleese on Chapman in The Pythons Autobiography by The Pythons (2003).

Along with Gilliam's animations, Cleese's work with Graham Chapman provided Python with its darkest and angriest moments, and many of his characters display the seething suppressed rage that later characterised his portrayal of Basil Fawlty.

Unlike Palin and Jones, Cleese and Chapman wrote together in the same room; Cleese claims that their writing partnership involved him doing most of the work, while Chapman sat back, not speaking for long periods before suddenly coming out with an idea that often elevated the sketch to a new level. A classic example of this is the "Dead Parrot sketch", envisaged by Cleese as a satire on poor customer service, which was originally to have involved a broken toaster and later a broken car (this version was actually performed and broadcast on the pre-Python special How to Irritate People). It was Chapman's suggestion to change the faulty item into a dead parrot, and he also suggested that the parrot be specifically a "Norwegian Blue", giving the sketch a surreal air which made it far more memorable.

Their humour often involved ordinary people in ordinary situations behaving absurdly for no obvious reason. Like Chapman, Cleese's poker face, clipped middle class accent, and intimidating height allowed him to appear convincingly as a variety of authority figures, such as policemen, detectives, Nazi officers or government officials, which he then proceeded to undermine. In the "Ministry of Silly Walks" sketch (written by Palin and Jones), for example, Cleese exploits his stature as the crane-legged civil servant performing a grotesquely elaborate walk to his office. On the Silly Walks sketch, Ben Beaumont-Thomas in The Guardian writes, "Cleese is utterly deadpan as he takes the stereotypical bowler-hatted political drone and ruthlessly skewers him. All the self-importance, bureaucratic inefficiency and laughable circuitousness of Whitehall is summed up in one balletic extension of his slender leg."

"Argument Clinic" sketch with Palin (standing) at Monty Python Live (Mostly), in 2014

Chapman and Cleese also specialised in sketches wherein two characters conducted highly articulate arguments over completely arbitrary subjects, such as in the "cheese shop", the "dead parrot" sketch and "Argument Clinic", where Cleese plays a stone-faced bureaucrat employed to sit behind a desk and engage people in pointless, trivial bickering. All of these roles were opposite Palin (who Cleese often claims is his favourite Python to work with)—the comic contrast between the towering Cleese's crazed aggression and the shorter Palin's shuffling inoffensiveness is a common feature in the series. Occasionally, the typical Cleese–Palin dynamic is reversed, as in "Fish Licence", wherein Palin plays the bureaucrat with whom Cleese is trying to work.

Though Flying Circus lasted four series, by the start of series 3, Cleese was growing tired of dealing with Chapman's alcoholism. He felt, too, that the show's scripts had declined in quality. For these reasons, he became restless and decided to move on. Though he stayed for the third series, he officially left the group before the fourth season. Cleese received a credit on three episodes of the fourth series which used material from these sessions, though he was officially unconnected with the fourth series. He remained friendly with the group, and all six began writing Monty Python and the Holy Grail. Much of his work on Holy Grail remains widely quoted, including the Black Knight scene. Cleese returned to the troupe to co-write and co-star in two further Monty Python films, Monty Python's Life of Brian and Monty Python's The Meaning of Life. His attack on Roman rule in Life of Brian–when he asks "What have the Romans ever done for us?", before being met with a string of benefits including sanitation, roads and public order–was ranked the seventh funniest line in film in a 2002 poll. Since the last Python film (Meaning of Life in 1983) Cleese has participated in various live performances with the group over the years.

1970–1979: Fawlty Towers

From 1970 to 1973, Cleese served as rector of the University of St Andrews. His election proved a milestone for the university, revolutionising and modernising the post. For instance, the rector was traditionally entitled to appoint an "assessor", a deputy to sit in his place at important meetings in his absence. Cleese changed this into a position for a student, elected across campus by the student body, resulting in direct access and representation for the student body.

Around this time, Cleese worked with comedian Les Dawson on his sketch/stand-up show Sez Les. The differences between the two physically (the tall, lean Cleese and the short, stout Dawson) and socially (the public school and the Cambridge-educated Cleese vs. the working class, self-educated Mancunian Dawson) were marked, but both worked well together from series 8 onwards until the series ended in 1976.

Cleese appeared on a single, "Superspike", with Bill Oddie and a group of UK athletes, billed the "Superspike Squad", to fund the latter's attendance at the 1976 Summer Olympics in Montreal.

Cleese starred in the low-budget spoof of the Sherlock Holmes detective series The Strange Case of the End of Civilization as We Know It (1977) as the grandson of the world's greatest consulting detective. In December 1977, Cleese appeared as a guest star on The Muppet Show. Ranked one of the best guest stars to appear on the show, Cleese was a fan of The Muppet Show and co-wrote much of the episode. In it he is "kidnapped" before the show begins, complains about the number of pigs, and gets roped into doing a closing number with Kermit the Frog, Sweetums, pigs, chickens and monsters. Cleese also made a cameo appearance in their 1981 film The Great Muppet Caper and won the TV Times award for Funniest Man on TV – 1978–79. In 1979, he starred in a TV special, To Norway, Home of Giants, produced by Johnny Bergh.

Throughout the 1970s, Cleese also produced and acted in a number of successful business training films, including Meetings, Bloody Meetings, and More Bloody Meetings. These were produced by his company Video Arts.

Fawlty Towers

Cleese achieved greater prominence in the United Kingdom as the neurotic hotel manager Basil Fawlty in the two series of Fawlty Towers, first broadcast 1975 and 1979, which he co-wrote with his wife Connie Booth. The series won three BAFTA awards when produced, and in 2000 it topped the British Film Institute's list of the 100 Greatest British Television Programmes. In a 2001 poll conducted by Channel 4 Basil Fawlty was ranked second (behind Homer Simpson) on their list of the 100 Greatest TV Characters. The series also featured Prunella Scales as Basil's acerbic wife Sybil, Andrew Sachs as the much abused Spanish waiter Manuel, and Booth as waitress Polly, the series' voice of sanity. Cleese based Basil Fawlty on a real person, Donald Sinclair, whom he had encountered in 1970 while the Monty Python team were staying at the Gleneagles Hotel in Torquay while filming inserts for their television series. Reportedly, Cleese was inspired by Sinclair's mantra, "I could run this hotel just fine if it weren't for the guests." He later described Sinclair as "the most wonderfully rude man I have ever met," although Sinclair's widow has said her husband was totally misrepresented in the series. During the Pythons' stay, Sinclair allegedly threw Idle's briefcase out of the hotel "in case it contained a bomb," complained about Gilliam's "American" table manners, and threw a bus timetable at another guest after he dared to ask the time of the next bus to town.

The first series was screened from 19 September 1975 on BBC 2, initially to poor reviews, but gained momentum when repeated on BBC 1 the following year. Despite this, a second series did not air until 1979, by which time Cleese's marriage to Booth had ended, but they revived their collaboration for the second series. Fawlty Towers consisted of two seasons, each of only six episodes; Cleese and Booth both maintain that this was to avoid compromising the quality of the series. The popularity of Fawlty Towers has endured, and in addition to featuring high in greatest-ever television show polls it is often rebroadcast. In a 2002 poll, Basil's "don't mention the war" comment (said to the waitress Polly about the German guests) was ranked the second funniest line in television.

1980–1999

During the 1980s and 1990s, Cleese focused on film, though he did work with Peter Cook in his one-off TV special Peter Cook and Co. in 1980. In the same year, Cleese played Petruchio, in Shakespeare's The Taming of the Shrew in the BBC Television Shakespeare series. In 1981 he appeared in the Terry Gilliam-directed Time Bandits as Robin Hood. He also participated in Monty Python Live at the Hollywood Bowl (filmed 1980, released 1982) and starred in The Secret Policeman's Ball for Amnesty International. In 1985, Cleese had a small dramatic role as a sheriff in the American Western Silverado, which had an all-star cast that included Kevin Kline, with whom he starred in A Fish Called Wanda three years later. In 1986, he starred in the British comedy film Clockwise as an uptight school headmaster obsessed with punctuality and constantly getting into trouble during a journey to speak at the Headmasters' Conference. Written by Michael Frayn, the film was successful in the UK but not in the United States. It earned Cleese the 1987 Peter Sellers Award For Comedy at the Evening Standard British Film Awards.

Cleese appearing at the 61st Academy Awards in March 1989

In 1988, Cleese wrote and starred in A Fish Called Wanda as the lead, Archie Leach, along with Jamie Lee Curtis, Kevin Kline, and Michael Palin. Wanda was a commercial and critical success, becoming one of the top ten films of the year at the US box office, and Cleese was nominated for an Academy Award for his script. Kline won the Oscar for his portrayal of bumbling, violent, narcissistic ex-CIA agent Otto West in the film.

From 1988 to 1992, Cleese appeared in numerous television commercials for Schweppes Ginger Ale. Between 1992 and 1994, he also appeared in some television commercials for Magnavox.

In 1989, Graham Chapman was diagnosed with throat cancer; Cleese, Michael Palin, Peter Cook, and Chapman's partner David Sherlock witnessed Chapman's death. Chapman's death occurred a day before the 20th anniversary of the first broadcast of Flying Circus, with Jones commenting that it was "the worst case of party-pooping in all history." Cleese gave a eulogy at Chapman's memorial service.

Cleese later played a supporting role in Kenneth Branagh's adaptation of Mary Shelley's Frankenstein (1994) alongside Branagh himself and Robert De Niro. With Robin Skynner, the English psychiatrist, Cleese wrote two books on relationships: Families and How to Survive Them and Life and How to Survive It. The books are presented as a dialogue between Skynner and Cleese.

The follow-up to A Fish Called Wanda, Fierce Creatures—which again starred Cleese alongside Kevin Kline, Jamie Lee Curtis, and Michael Palin—was released in 1997, but was greeted with mixed reception by critics and audiences. Cleese has since often stated that making the second film had been a mistake. When asked by his friend, director and restaurant critic Michael Winner, what he would do differently if he could live his life again, Cleese responded, "I wouldn't have married Alyce Faye Eichelberger and I wouldn't have made Fierce Creatures."

In 1999, Cleese appeared in the James Bond film The World Is Not Enough as Q's assistant, referred to by Bond as "R". In 2002, when Cleese reprised his role in Die Another Day, the character was promoted, making Cleese the new quartermaster (Q) of MI6. In 2004, Cleese was featured as Q in the video game James Bond 007: Everything or Nothing, featuring his likeness and voice. Cleese did not appear in the subsequent Bond films, Casino Royale, Quantum of Solace and Skyfall; in the latter film, Ben Whishaw was cast in the role of Q.

2000–2009

Cleese is Provost's visiting professor at Cornell University, after having been Andrew D. White Professor-at-Large from 1999 to 2006. He makes occasional well-received appearances on the Cornell campus. In 2001, Cleese was cast in the comedy Rat Race as the eccentric hotel owner Donald P. Sinclair, the name of the Torquay hotel owner on whom he had based the character of Basil Fawlty. That year he appeared as Nearly Headless Nick in the first Harry Potter film: Harry Potter and the Philosopher's Stone (2001), a role he would reprise in Harry Potter and the Chamber of Secrets (2002). In 2002, Cleese made a cameo appearance in the film The Adventures of Pluto Nash, in which he played "James", a computerised chauffeur of a hover car stolen by the title character (played by Eddie Murphy). The vehicle is subsequently destroyed in a chase, leaving the chauffeur stranded in a remote place on the moon. In 2003, Cleese appeared as Lyle Finster on the US sitcom Will & Grace. His character's daughter, Lorraine, was played by Minnie Driver. In the series, Lyle Finster briefly marries Karen Walker (Megan Mullally). In 2004, Cleese was credited as co-writer of a DC Comics graphic novel titled Superman: True Brit. Part of DC's "Elseworlds" line of imaginary stories, True Brit, mostly written by Kim Howard Johnson, suggests what might have happened had Superman's rocket ship landed on a farm in Britain, not America.

Cleese in 2008

From 10 November to 9 December 2005, Cleese toured New Zealand with his stage show John Cleese—His Life, Times and Current Medical Problems. Cleese described it as "a one-man show with several people in it, which pushes the envelope of acceptable behaviour in new and disgusting ways". The show was developed in New York City with William Goldman and includes Cleese's daughter Camilla as a writer and actor (the shows were directed by Australian Bille Brown). His assistant of many years, Garry Scott-Irvine, also appeared and was listed as a co-producer. The show then played in universities in California and Arizona from 10 January to 25 March 2006 under the title Seven Ways to Skin an Ocelot. His voice can be downloaded for directional guidance purposes as a downloadable option on some personal GPS-navigation device models by company TomTom.

In a 2005 poll of comedians and comedy insiders, The Comedians' Comedian, Cleese was voted second to Peter Cook. In 2006, Cleese hosted a television special of football's greatest kicks, goals, saves, bloopers, plays, and penalties, as well as football's influence on culture (including the Monty Python sketch "Philosophy Football"), featuring interviews with pop culture icons Dave Stewart, Dennis Hopper, and Henry Kissinger, as well as eminent footballers, including Pelé, Mia Hamm, and Thierry Henry. The Art of Soccer with John Cleese was released in North America on DVD in January 2009 by BFS Entertainment & Multimedia. Also in 2006, Cleese released the song "Don't Mention the World Cup".

Cleese lent his voice to the BioWare video game Jade Empire. His role was that of an "outlander" named Sir Roderick Ponce von Fontlebottom the Magnificent Bastard, stranded in the Imperial City of the Jade Empire. His character is essentially a British colonialist stereotype who refers to the people of the Jade Empire as "savages in need of enlightenment". His armour has the design of a fork stuck in a piece of cheese. In 2007, Cleese appeared in ads for Titleist as a golf course designer named "Ian MacCallister", who represents "Golf Designers Against Distance". Also in 2007, he was involved in filming of the sequel to The Pink Panther, titled The Pink Panther 2, with Steve Martin and Aishwarya Rai.

Cleese collaborated with Los Angeles Guitar Quartet member William Kanengiser in 2008 on the text to the performance piece "The Ingenious Gentleman of La Mancha". Cleese, as narrator, and the LAGQ premiered the work in Santa Barbara. The year 2008 also saw reports of Cleese working on a musical version of A Fish Called Wanda with his daughter Camilla.

At the end of March 2009, Cleese published his first article as "Contributing Editor" to The Spectator: "The real reason I had to join The Spectator". Cleese has also hosted comedy galas at the Montreal Just for Laughs comedy festival in 2006, and again in 2009. Towards the end of 2009 and into 2010, Cleese appeared in a series of television adverts for the Norwegian electric goods shop chain Elkjøp. In March 2010 it was announced that Cleese would be playing Jasper in the video game Fable III.

In 2009 and 2010, Cleese toured Scandinavia and the US with his Alimony Tour Year One and Year Two. In May 2010, it was announced that this tour, set for May 2011, would extend to the UK (his first tour there). The show is dubbed the "Alimony Tour" in reference to the financial implications of Cleese's divorce. The UK tour started in Cambridge on 3 May, visiting Birmingham, Nottingham, Salford, York, Liverpool, Leeds, Glasgow, Edinburgh, Oxford, Bristol and Bath (the Alimony Tour DVD was recorded on 2 July, the final Bath date). Later in 2011 John took his Alimony Tour to South Africa. He played Cape Town on the 21 & 22 October before moving over to Johannesburg, where he played from 25 to 30 October. In January 2012 he took his one-man show to Australia, starting in Perth on 22 January and throughout the next four months visited Adelaide, Brisbane, Gold Coast, Newcastle, New South Wales, Melbourne, Sydney, and finished up during April in Canberra.

2010–present

In October 2010, Cleese was featured in the launch of an advertising campaign by The Automobile Association for a new home emergency response product. He appeared as a man who believed the AA could not help him during a series of disasters, including water pouring through his ceiling, with the line "The AA? For faulty showers?" During 2010, Cleese appeared in a series of radio advertisements for the Canadian insurance company Pacific Blue Cross, in which he plays a character called "Dr. Nigel Bilkington, Chief of Medicine for American General Hospital".

In 2012, Cleese was cast in Hunting Elephants, a heist comedy by Israeli filmmaker Reshef Levi. Cleese had to quit just prior to filming due to heart trouble and was replaced by Patrick Stewart. Between September and October 2013, Cleese embarked on his first-ever cross-Canada comedy tour. Entitled "John Cleese: Last Time to See Me Before I Die tour", he visited Halifax, Ottawa, Toronto, Edmonton, Calgary, Victoria and finished in Vancouver, performing to mostly sold-out venues. Cleese returned to the stage in Dubai in November 2013, where he performed to a sold-out theatre.

Cleese (right) with the rest of Monty Python on stage at the O2 Arena, London, in July 2014

Cleese was interviewed and appears as himself in filmmaker Gracie Otto's 2013 documentary film The Last Impresario, about Cleese's longtime friend and colleague Michael White. White produced Monty Python and the Holy Grail and Cleese's pre-Python comedy production Cambridge Circus. At a comic press conference in November 2013, Cleese and other surviving members of the Monty Python comedy group announced a reuniting performance to be held in July 2014.

Cleese joined with Eric Idle in 2015 and 2016 for a tour of North America, Canada and the ANZUS nations, "John Cleese & Eric Idle: Together Again At Last . . . For The Very First Time," playing small theatres and including interaction with audiences as well as sketches and reminisces. In a Reddit Ask Me Anything interview, Cleese expressed regret that he had turned down the role played by Robin Williams in The Birdcage, the butler played by Anthony Hopkins in The Remains of the Day, and the clergyman played by Peter Cook in The Princess Bride.

In 2017, he wrote Bang Bang! a new adaptation of Georges Feydeau's French play Monsieur Chasse! for the Mercury Theatre, Colchester, before making its American premiere at the Shadowland Stages in Ellenville, New York in 2018 followed by touring the UK in spring 2020.

In 2021, Cleese cancelled an appearance at Cambridge University after learning that art historian Andrew Graham-Dixon had been blacklisted by the student union for impersonating Adolf Hitler. His visit to the university was intended to be part of a documentary on wokeism. Cleese said he was "blacklisting myself before someone else does".

In 2023, he starred in Roman Polanski's drama film The Palace. In October, Cleese starting presenting a new show on GB News called The Dinosaur Hour which airs on Sunday evenings.

Style of humour

Graffiti of Cleese in "The Ministry of Silly Walks" sketch in Monty Python—Leicester, 2007

In his Alimony Tour Cleese explained the origin of his fondness for black humour, the only thing that he inherited from his mother. Examples of it are the Dead Parrot sketch, "The Kipper and the Corpse" episode of Fawlty Towers, his clip for the 1992 BBC2 mockumentary "A Question of Taste", the Undertakers sketch, and his eulogy at Graham Chapman's memorial service which included the line, "Good riddance to him, the freeloading bastard! I hope he fries." On his attitude to life he states, "I can take almost nothing seriously".

Cleese has criticised political correctness, wokeism and cancel culture, saying that despite initial good intentions to "not be mean to people", they have become "a sort of indulgence of the most over-sensitive people in your culture, the people who are most easily upset [...] if you have to keep thinking which words you can use and which you can't, then that will stifle creativity." According to Cleese, "The main thing is to realise that words depend on their context [...] PC people simply don't understand this business about context because they tend to be very literal-minded", and that he imagined a "woke joke [...] might be heart-warming but it's not going to be very funny." He has also argued that political correctness and wokeism are a threat to humour, creativity, and freedom of thought and expression.

In 2020, following a controversy over the content of the Fawlty Towers episode "The Germans", Cleese criticised the BBC, saying "The BBC is now run by a mixture of marketing people and petty bureaucrats. It used to have a large sprinkling of people who'd actually made programmes. Not any more. So BBC decisions are made by persons whose main concern is not losing their jobs... That's why they're so cowardly and gutless and contemptible." He likened the style of humour in Fawlty Towers to the representation of Alf Garnett from another BBC sitcom, Till Death Us Do Part, saying "We laughed at Alf's reactionary views. Thus we discredited them, by laughing at him. Of course, there were people—very stupid people—who said 'Thank God someone is saying these things at last'. We laughed at these people too. Now they're taking decisions about BBC comedy."

Activism and politics

Amnesty first started doing these fund-raising shows in 1976. The instigation came from John Cleese who wanted to help out. And he did it in the only way he knew how. Which was to put on a show with what he described as "a few friends". Who of course transpired to be his colleagues in Monty Python and other luminaries of British comedy.

Martin Lewis, co-founder of The Secret Policeman's Ball, on Cleese instigating the benefit show.

Cleese (and the other members of Python) have contributed their services to charitable endeavours and causes—sometimes as an ensemble, at other times as individuals. The cause that has been the most frequent and consistent beneficiary has been the human rights work of Amnesty International via the Secret Policeman's Ball benefit shows. The idea of the Ball was conceived by Cleese, with Huffington Post stating "in 1976 he "friended" the then-struggling Amnesty International (according to Martin Lewis, the very notion of Human Rights was then not the domain of hipsters and students, but just of foreign-policy wonks) first with a cheque signed "J. Cleese" — and then by rounding up "a few friends" to put on a show." Many musicians have publicly attributed their activism—and the organisation of their own benefit events—to the inspiration of the work in this field of Cleese and the rest of Python, such as Bob Geldof (organiser of Live Aid), U2, Pete Townshend, and Sting. On the impact of the Ball on Geldof, Sting states, "he took the 'Ball' and ran with it."

Cleese, in 2022, spoke at the conference of the revival Social Democratic Party. Previously, he was a long-standing supporter of the Liberal Democrats and before that was a supporter of the original SDP after their formation in 1981. During the 1987 general election he recorded a party political broadcast for the SDP–Liberal Alliance, in which he advocated for the introduction of proportional representation. Cleese subsequently appeared in broadcasts for the Liberal Democrats in the 1997 general election and narrated a radio election broadcast for the party during the 2001 general election.

In 2008, Cleese expressed support for Barack Obama and his presidential candidacy, offering his services as a speech writer. He was an outspoken critic of Republican Vice-Presidential candidate Sarah Palin, saying that "Michael Palin is no longer the funniest Palin". The same year, he wrote a satirical poem about Fox News commentator Sean Hannity for Countdown with Keith Olbermann.

In 2011, Cleese declared his appreciation for Britain's coalition government between the Conservatives and Liberal Democrats, saying: "I think what's happening at the moment is rather interesting. The Coalition has made everything a little more courteous and a little more flexible. I think it was quite good that the Liberal Democrats had to compromise a bit with the Tories." He also criticised the previous Labour government, commenting: "Although my inclinations are slightly left-of-centre, I was terribly disappointed with the last Labour government. Gordon Brown lacked emotional intelligence and was never a leader." Cleese also reiterated his support for proportional representation.

In April 2011, Cleese said that he had declined a life peerage for political services in 1999. Outgoing leader of the Liberal Democrats Paddy Ashdown had put forward the suggestion shortly before stepping down, with the idea that Cleese would take the party whip and sit as a working peer, but the actor quipped that he "realised this involved being in England in the winter and I thought that was too much of a price to pay." Cleese also declined a CBE title in 1996 as he thought, "they were silly."

In an interview with The Daily Telegraph in 2014, Cleese expressed political interest about the UK Independence Party, saying that although he was in doubt as to whether he was prepared to vote for it, he was attracted to its challenge to the established political order and the radicalism of its policies on the United Kingdom's membership of the European Union. He expressed support for immigration, but also concern about the integration of immigrants into British culture.

Talking to Der Spiegel in 2015, Cleese expressed a critical view on what he saw as a plutocracy that was unhealthily developing control of the governance of the First World's societies, stating that he had reached a point when he "saw that our existence here is absolutely hopeless. I see the rich have got a stranglehold on us. If somebody had said that to me when I was 20, I would have regarded him as a left-wing loony."

In 2016, Cleese publicly supported Brexit in the 2016 referendum on leaving the European Union. He tweeted: "If I thought there was any chance of major reform in the EU, I'd vote to stay in. But there isn't. Sad." Cleese said that "EU bureaucrats" had taken away "any trace of democratic accountability" and suggested they should "give up the euro, introduce accountability."

During then-Republican nominee Donald Trump's run for the US presidency in 2016, Cleese described Trump as "a narcissist, with no attention span, who doesn't have clear ideas about anything and makes it all up as he goes along". He had previously described the leadership of the Republican Party as "the most cynical, most disgracefully immoral people I've ever come across in a Western civilisation".

In 2017, Cleese stated that he would not vote in that year's general election because "I live in Chelsea and Kensington, so under our present system my vote is utterly worthless." In July 2018, Cleese said that he was leaving the UK to relocate to the Caribbean island of Nevis, partly over frustration around the standard of the Brexit debate, including "dreadful lies" by "the right" and a lack of reform regarding the press and the voting system. He relocated to Nevis on 1 November 2018.

In May 2019, Cleese repeated his previous statement that London was no longer an English city, saying "virtually all my friends from abroad have confirmed my observation. So there must be some truth in it... I note also that London was the UK city that voted most strongly to remain in the EU." London Mayor Sadiq Khan responded, "These comments make John Cleese sound like he's in character as Basil Fawlty. Londoners know that our diversity is our greatest strength. We are proudly the English capital, a European city and a global hub." Cleese added, "I suspect I should apologise for my affection for the Englishness of my upbringing, but in some ways I found it calmer, more polite, more humorous, less tabloid, and less money-oriented than the one that is replacing it."

In 2020, Cleese opposed the BBC's removal of the Fawlty Towers episode "The Germans" from the UKTV streaming service after protests following the murder of George Floyd, stating that the program was mocking prejudice with its use of a character who uttered racial slurs. "If they can't see that, if people are too stupid to see that, what can one say," said Cleese. UKTV later restored the episode with a disclaimer about its content.

In November 2021, Cleese protested against perceived cancel culture by blacklisting himself over a Hitler impersonation controversy at the Cambridge Union.

Anti-smoking campaign

In 1992, the UK Health Education Authority (subsequently the Health Development Agency, now merged into the National Institute for Health and Care Excellence) recruited Cleese—an ex-smoker—to star in a series of anti-smoking public service announcements (PSAs) on British television, which took the form of sketches rife with morbid humour about smoking and were designed to encourage adult smokers to quit. In a controlled study of regions of central and northern England (one region received no intervention) the PSAs were broadcast in two regions, and one region received both the PSAs, plus locally organised anti-tobacco campaigning. The study found:

After 18 months, 9.8% of successfully re-interviewed smokers had stopped and 4.3% of ex-smokers had relapsed. [...] There was no evidence of an extra effect of the local tobacco control network when combined with TV media [...] Applying these results to a typical population where 28% smoke and 28% are ex-smokers, and where there would be an equal number of quitters and relapsers over an 18 month period without the campaign, suggests that the campaign would reduce smoking prevalence by about 1.2%.

Personal life

Cleese met Connie Booth in the US and they married in 1968. In 1971, Booth gave birth to their only child, Cynthia Cleese, who went on to appear with her father in his films A Fish Called Wanda and Fierce Creatures. With Booth, Cleese wrote the scripts for and co-starred in both series of Fawlty Towers, although the two were actually divorced before the second series was finished and aired. Cleese and Booth are said to have remained close friends since. Cleese has two grandchildren, Evan and Olivia, through Cynthia's marriage to writer/director Ed Solomon. Cleese married American actress Barbara Trentham in 1981. Their daughter Camilla, Cleese's second child, was born in 1984. He and Trentham divorced in 1990. During this time, Cleese emigrated to Los Angeles.

In 1992, he married American psychotherapist Alyce Faye Eichelberger. They divorced in 2008; the divorce settlement left Eichelberger with £12 million in finance and assets, including £600,000 a year for seven years. Cleese said, "What I find so unfair is that if we both died today, her children would get much more than mine ... I got off lightly. Think what I'd have had to pay Alyce if she had contributed anything to the relationship—such as children, or a conversation".

Less than a year later, he returned to the UK, where he has property in London and a home on the Royal Crescent in Bath, Somerset. In August 2012, Cleese married English jewellery designer and former model Jennifer Wade in a ceremony on the Caribbean island of Mustique.

In an interview in 2014, Cleese blamed his mother, who lived to the age of 101, for his problems in relationships with women, saying: "My ingrained habit of walking on eggshells when dealing with my mother dominated my romantic liaisons for many years." Cleese said that he had spent "a large part of my life in some form of therapy" over his relationships with women.

In March 2015, in an interview with Der Spiegel, he was asked if he was religious. Cleese stated that he did not think much of organised religion and said he was not committed to "anything except the vague feeling that there is something more going on than the materialist reductionist people think".

Cleese has a passion for lemurs. Following the 1997 comedy film Fierce Creatures, in which the ring-tailed lemur played a key role, he hosted the 1998 BBC documentary In the Wild: Operation Lemur with John Cleese, which tracked the progress of a reintroduction of black-and-white ruffed lemurs back into the Betampona Reserve in Madagascar. The project had been partly funded by Cleese's donation of the proceeds from the London premiere of Fierce Creatures. Cleese said "I adore lemurs. They're extremely gentle, well-mannered, pretty and yet great fun ... I should have married one".

The Bemaraha woolly lemur (Avahi cleesei), also known as Cleese's woolly lemur, is native to western Madagascar. The scientist who discovered the species named it after Cleese, mainly because of Cleese's fondness for lemurs and his efforts at protecting and preserving them. The species was first discovered in 1990 by a team of scientists from the University of Zurich led by Urs Thalmann but was not formally described as a species until 11 November 2005.

Filmography

Awards and nominations

Year Association Category Nominated work Result
1988 Academy Award Original Screenplay A Fish Called Wanda Nominated
1988 Golden Globe Award Best Actor in a Motion Picture – Comedy of Musical Nominated
1988 BAFTA Film Award Best Actor Won
Best Original Screenplay Nominated
1971 BAFTA Television Award Best Entertainment Performance Monty Python’s Flying Circus Nominated
1976 Fawlty Towers Nominated
1980 Won
1987 Emmy Awards Outstanding Guest Actor in a Comedy Series Cheers Won
1998 3rd Rock from the Sun Nominated
2002 Outstanding Non-Fiction Special The Human Face Nominated
2004 Outstanding Guest Actor in a Comedy Series Will & Grace Nominated
1976 Grammy Awards Best Comedy Album The Monty Python Matching Tie and Handkerchief Nominated
1981 Monty Python's Contractual Obligation Album Nominated
1984 Monty Python’s The Meaning of Life Nominated
1989 Best Spoken Word Album The Screwtape Letters Nominated
1994 Best Spoken Word Album for Children Did I Ever Tell You How Lucky You Are? Nominated

Honours and tributes

  • A species of lemur, the Bemaraha woolly lemur (Avahi cleesei), has been named in his honour. John Cleese has mentioned this in television interviews. Also there is mention of this honour in "New Scientist"—and John Cleese's response to the honour.
  • An asteroid, 9618 Johncleese, is named in his honour.
  • There is a municipal rubbish heap of 45 metres (148 ft) in altitude that has been named Mt Cleese at the Awapuni landfill just outside Palmerston North after he dubbed the city "suicide capital of New Zealand" after a stay there in 2005.

Reference (computer science)

From Wikipedia, the free encyclopedia

In computer programming, a reference is a value that enables a program to indirectly access a particular data, such as a variable's value or a record, in the computer's memory or in some other storage device. The reference is said to refer to the datum, and accessing the datum is called dereferencing the reference. A reference is distinct from the datum itself.

A reference is an abstract data type and may be implemented in many ways. Typically, a reference refers to data stored in memory on a given system, and its internal value is the memory address of the data, i.e. a reference is implemented as a pointer. For this reason a reference is often said to "point to" the data. Other implementations include an offset (difference) between the datum's address and some fixed "base" address, an index, or identifier used in a lookup operation into an array or table, an operating system handle, a physical address on a storage device, or a network address such as a URL.

Formal representation

A reference R is a value that admits one operation, dereference(R), which yields a value. Usually the reference is typed so that it returns values of a specific type, e.g.:

interface Reference<T> {
  T value();
}

Often the reference also admits an assignment operation store(R, x), meaning it is an abstract variable.

Use

References are widely used in programming, especially to efficiently pass large or mutable data as arguments to procedures, or to share such data among various uses. In particular, a reference may point to a variable or record that contains references to other data. This idea is the basis of indirect addressing and of many linked data structures, such as linked lists. References increase flexibility in where objects can be stored, how they are allocated, and how they are passed between areas of code. As long as one can access a reference to the data, one can access the data through it, and the data itself need not be moved. They also make sharing of data between different code areas easier; each keeps a reference to it.

References can cause significant complexity in a program, partially due to the possibility of dangling and wild references and partially because the topology of data with references is a directed graph, whose analysis can be quite complicated. Nonetheless, references are still simpler to analyze than pointers due to the absence of pointer arithmetic.

The mechanism of references, if varying in implementation, is a fundamental programming language feature common to nearly all modern programming languages. Even some languages that support no direct use of references have some internal or implicit use. For example, the call by reference calling convention can be implemented with either explicit or implicit use of references.

Examples

Pointers are the most primitive type of reference. Due to their intimate relationship with the underlying hardware, they are one of the most powerful and efficient types of references. However, also due to this relationship, pointers require a strong understanding by the programmer of the details of memory architecture. Because pointers store a memory location's address, instead of a value directly, inappropriate use of pointers can lead to undefined behavior in a program, particularly due to dangling pointers or wild pointers. Smart pointers are opaque data structures that act like pointers but can only be accessed through particular methods.

A handle is an abstract reference, and may be represented in various ways. A common example are file handles (the FILE data structure in the C standard I/O library), used to abstract file content. It usually represents both the file itself, as when requesting a lock on the file, and a specific position within the file's content, as when reading a file.

In distributed computing, the reference may contain more than an address or identifier; it may also include an embedded specification of the network protocols used to locate and access the referenced object, the way information is encoded or serialized. Thus, for example, a WSDL description of a remote web service can be viewed as a form of reference; it includes a complete specification of how to locate and bind to a particular web service. A reference to a live distributed object is another example: it is a complete specification for how to construct a small software component called a proxy that will subsequently engage in a peer-to-peer interaction, and through which the local machine may gain access to data that is replicated or exists only as a weakly consistent message stream. In all these cases, the reference includes the full set of instructions, or a recipe, for how to access the data; in this sense, it serves the same purpose as an identifier or address in memory.

If we have a set of keys K and a set of data objects D, any well-defined (single-valued) function from K to D ∪ {null} defines a type of reference, where null is the image of a key not referring to anything meaningful.

An alternative representation of such a function is a directed graph called a reachability graph. Here, each datum is represented by a vertex and there is an edge from u to v if the datum in u refers to the datum in v. The maximum out-degree is one. These graphs are valuable in garbage collection, where they can be used to separate accessible from inaccessible objects.

External and internal storage

In many data structures, large, complex objects are composed of smaller objects. These objects are typically stored in one of two ways:

  1. With internal storage, the contents of the smaller object are stored inside the larger object.
  2. With external storage, the smaller objects are allocated in their own location, and the larger object only stores references to them.

Internal storage is usually more efficient, because there is a space cost for the references and dynamic allocation metadata, and a time cost associated with dereferencing a reference and with allocating the memory for the smaller objects. Internal storage also enhances locality of reference by keeping different parts of the same large object close together in memory. However, there are a variety of situations in which external storage is preferred:

  • If the data structure is recursive, meaning it may contain itself. This cannot be represented in the internal way.
  • If the larger object is being stored in an area with limited space, such as the stack, then we can prevent running out of storage by storing large component objects in another memory region and referring to them using references.
  • If the smaller objects may vary in size, it is often inconvenient or expensive to resize the larger object so that it can still contain them.
  • References are often easier to work with and adapt better to new requirements.

Some languages, such as Java, Smalltalk, Python, and Scheme, do not support internal storage. In these languages, all objects are uniformly accessed through references.

Language support

Assembly

In assembly language, it is typical to express references using either raw memory addresses or indexes into tables. These work, but are somewhat tricky to use, because an address tells you nothing about the value it points to, not even how large it is or how to interpret it; such information is encoded in the program logic. The result is that misinterpretations can occur in incorrect programs, causing bewildering errors.

Lisp

One of the earliest opaque references was that of the Lisp language cons cell, which is simply a record containing two references to other Lisp objects, including possibly other cons cells. This simple structure is most commonly used to build singly linked lists, but can also be used to build simple binary trees and so-called "dotted lists", which terminate not with a null reference but a value.

C/C++

The pointer is still one of the most popular types of references today. It is similar to the assembly representation of a raw address, except that it carries a static datatype which can be used at compile-time to ensure that the data it refers to is not misinterpreted. However, because C has a weak type system which can be violated using casts (explicit conversions between various pointer types and between pointer types and integers), misinterpretation is still possible, if more difficult. Its successor C++ tried to increase type safety of pointers with new cast operators, a reference type &, and smart pointers in its standard library, but still retained the ability to circumvent these safety mechanisms for compatibility.

Fortran

Fortran does not have an explicit representation of references, but does use them implicitly in its call-by-reference calling semantics. A Fortran reference is best thought of as an alias of another object, such as a scalar variable or a row or column of an array. There is no syntax to dereference the reference or manipulate the contents of the referent directly. Fortran references can be null. As in other languages, these references facilitate the processing of dynamic structures, such as linked lists, queues, and trees.

Object-oriented languages

A number of object-oriented languages languages such as Eiffel, Java, C#, and Visual Basic have adopted a much more opaque type of reference, usually referred to as simply a reference. These references have types like C pointers indicating how to interpret the data they reference, but they are typesafe in that they cannot be interpreted as a raw address and unsafe conversions are not permitted. References are extensively used to access and assign objects. References are also used in function/method calls or message passing, and reference counts are frequently used to perform garbage collection of unused objects.

Functional languages

In Standard ML, OCaml, and many other functional languages, most values are persistent: they cannot be modified by assignment. Assignable "reference cells" provide mutable variables, data that can be modified. Such reference cells can hold any value, and so are given the polymorphic type α ref, where α is to be replaced with the type of value pointed to. These mutable references can be pointed to different objects over their lifetime. For example, this permits building of circular data structures. The reference cell is functionally equivalent to a mutable array of length 1.

To preserve safety and efficient implementations, references cannot be type-cast in ML, nor can pointer arithmetic be performed. In the functional paradigm, many structures that would be represented using pointers in a language like C are represented using other facilities, such as the powerful algebraic datatype mechanism. The programmer is then able to enjoy certain properties (such as the guarantee of immutability) while programming, even though the compiler often uses machine pointers "under the hood".

Perl/PHP

Perl supports hard references, which function similarly to those in other languages, and symbolic references, which are just string values that contain the names of variables. When a value that is not a hard reference is dereferenced, Perl considers it to be a symbolic reference and gives the variable with the name given by the value.[3] PHP has a similar feature in the form of its $$var syntax.[4]

Python

Python includes a wide range of references. Generally, programmers use id(var) to access the reference address of a variable var. Reference in Python is more complex than C++ or other programming languages.

A constant (for example, an integer 2) is an object in Python and therefore has a reference to a fixed address. When programmer calls an a = 2, the program creates a memory space for consonant 2 and arranges a reference to it. Then the program links the reference of a to the address of 2, which reveals that changing the value of a numerical variable changes the reference of it. Whereas in mutable types (for example, a list type), value changing won't change the variable's reference.

When a variable is passed as a function parameter, the function gets the reference to it by default, not its value. For mutable types, this causes the original variable easy to be modified; for immutable type, modifying its value in the function will cause the temporary variable reference in the function to be modified to otherwhere, hence will not cause the original variable to be changed.

 

Late binding

From Wikipedia, the free encyclopedia

In computing, late binding or dynamic linkage—though not an identical process to dynamically linking imported code libraries—is a computer programming mechanism in which the method being called upon an object, or the function being called with arguments, is looked up by name at runtime. In other words, a name is associated with a particular operation or object at runtime, rather than during compilation. The name dynamic binding is sometimes used, but is more commonly used to refer to dynamic scope.

With early binding, or static binding, in an object-oriented language, the compilation phase fixes all types of variables and expressions. This is usually stored in the compiled program as an offset in a virtual method table ("v-table"). In contrast, with late binding, the compiler does not read enough information to verify the method exists or bind its slot on the v-table. Instead, the method is looked up by name at runtime.

The primary advantage of using late binding in Component Object Model (COM) programming is that it does not require the compiler to reference the libraries that contain the object at compile time. This makes the compilation process more resistant to version conflicts, in which the class's v-table may be accidentally modified. (This is not a concern in just-in-time compiled platforms such as .NET or Java, because the v-table is created at runtime by the virtual machine against the libraries as they are being loaded into the running application.)

History

The term "late binding" dates back to at least the 1960s, where it can be found in Communications of the ACM. The term was widely used to describe calling conventions in languages like Lisp, though usually with negative connotations about performance.

In the 1980s Smalltalk popularized object-oriented programming (OOP) and with it late binding. Alan Kay once said, "OOP to me means only messaging, local retention, and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."

In the early to mid-1990s, Microsoft heavily promoted its COM standard as a binary interface between different OOP programming languages. COM programming equally promoted early and late binding, with many languages supporting both at the syntax level.

In 2000, Alex Martelli coined the term "duck typing" to refer to a similar concept, but with a different emphasis. While late binding generally focuses on implementation details, duck typing focuses on the ability to ignore types and concentrate on the methods an object currently has.

Late binding implementations

Late binding in dynamically-typed object-oriented languages

In most dynamically-typed languages, the list of methods on an object can be altered at runtime. This requires late binding.

Late binding in Lisp

In Lisp, late bound global function calls are efficiently looked up at runtime via a symbol's function cell. These function bindings are mutable.

Example using an interactive Clozure Common Lisp session:

? (defun foo ()
    (bar pi))   ; a still undefined function BAR gets called
;Compiler warnings :
;   In FOO: Undefined function BAR
FOO

? (defun bar (x)   ; now we define it
    (* x 2))
BAR

? (foo)    ; calling foo and it uses the recent definition of BAR
6.283185307179586D0

? (defun bar (x)   ; now we redefine BAR
    (* x 1000))
BAR

? (foo)    ;  FOO now calls the new function, there is no need to recompile/link/load FOO
3141.592653589793D0

? (type-of 'bar)   ;  BAR is a symbol
SYMBOL

? (symbol-function 'bar)  ; the symbol BAR has a function binding
#<Compiled-function BAR #x302000D1B21F>

Late binding in C++

In C++, late binding (also called "dynamic binding") refers to what normally happens when the virtual keyword is used in a method's declaration. C++ then creates a so-called virtual table, which is a look-up table for such functions that will always be consulted when they are called. Usually, the "late binding" term is used in favor of "dynamic dispatch".

Late binding in COM languages

In COM programming a late-bound method call is performed using the IDispatch interface. Some COM-based languages such as Visual Basic 6 have syntactical support for calling this interface. This is done by defining the variable's type as Object. Others such as C++ require that you explicitly call GetIDsOfNames to look up a method and Invoke to call it.

Late binding in .NET

In .NET, late binding refers to overriding a virtual method like C++ or implementing an interface. The compiler builds virtual tables for every virtual or interface method call which is used at run-time to determine the implementation to execute.

Also like COM and Java, the Common Language Runtime provides reflection APIs that can make late binding calls. The use of these calls varies by language.

With C# 4, the language also added the "dynamic" pseudo-type. This would be used in place of the Object type to indicate that late binding is desired. The specific late binding mechanism needed is determined at runtime using the Dynamic Language Runtime as a starting point.

Visual Basic uses them whenever the variable is of type Object and the compiler directive "Option Strict Off" is in force. This is the default setting for a new VB project. Prior to version 9, only .NET and COM objects could be late bound. With VB 10, this has been extended to DLR-based objects.

Late binding in Java

There are three definitions for late binding in Java.

Early documents on Java discussed how classes were not linked together at compile time. While types are statically checked at compile time, different implementations for classes could be swapped out just prior to runtime simply by overwriting the class file. As long as the new class definition had the same class and method names, the code would still work. In this sense it is similar to the traditional definition of late binding.

Currently, it is popular to use the term late binding in Java programming as a synonym for dynamic dispatch. Specifically, this refers to Java's single dispatch mechanism used with virtual methods.

Finally, Java can use late binding using its reflection APIs and type introspection much in the same way it is done in COM and .NET programming. Generally speaking those who only program in Java do not call this late binding. Likewise the use of "duck typing" techniques is frowned upon in Java programming, with abstract interfaces used instead.

Oracle, the current owner of Java, has been known to use the term late binding in the "duck typing" sense when discussing both Java and other languages in the same documentation.

Early vs. late binding in PL/SQL and Ada

When using early binding between Ada and a database-stored procedure, a timestamp is checked to verify that the stored procedure has not changed since the code was compiled. This allows for faster executions and prevents the application from running against the wrong version of a stored procedure.

When using late binding the timestamp check is not performed, and the stored procedure is executed via an anonymous PL/SQL block. While this can be slower, it removes the need to recompile all of the client applications when a stored procedure changes.

This distinction appears to be unique to PL/SQL and Ada. Other languages that can call PL/SQL procedures, as well as other database engines, only use late binding.

Criticism

Late binding has poorer performance than an early bound method call. Under most implementations, the correct method address must be looked up by name with each call, requiring relatively expensive dictionary search and possibly overload resolution logic. In most applications, the extra compute and time required is negligible on modern computers.

For some compilers, late binding may prevent the use of static type checking. When making a late bound call, the compiler has to assume that the method exists. This means a simple spelling error can cause a run-time error to be thrown. Modern compilers avoid this by ensuring that every possible call must have an implementation during compilation.

Late binding may prevent forms of static analysis needed by an integrated development environment (IDE). For example, an IDE's "go to definition" feature may not function on a late-bound call, if the IDE has no way to know which class the call may refer to. A modern IDE easily solves this especially for object-oriented languages since a late-bound method always specifies an interface or base class, which is where "go to definition" leads, and "find all references" can be used to find all implementations or overrides.

Smart pointer

From Wikipedia, the free encyclopedia

In computer science, a smart pointer is an abstract data type that simulates a pointer while providing added features, such as automatic memory management or bounds checking. Such features are intended to reduce bugs caused by the misuse of pointers, while retaining efficiency. Smart pointers typically keep track of the memory they point to, and may also be used to manage other resources, such as network connections and file handles. Smart pointers were first popularized in the programming language C++ during the first half of the 1990s as rebuttal to criticisms of C++'s lack of automatic garbage collection.

Pointer misuse can be a major source of bugs. Smart pointers prevent most situations of memory leaks by making the memory deallocation automatic. More generally, they make object destruction automatic: an object controlled by a smart pointer is automatically destroyed (finalized and then deallocated) when the last (or only) owner of an object is destroyed, for example because the owner is a local variable, and execution leaves the variable's scope. Smart pointers also eliminate dangling pointers by postponing destruction until an object is no longer in use.

If a language supports automatic garbage collection (for example, Java or C#), then smart pointers are unneeded for reclaiming and safety aspects of memory management, yet are useful for other purposes, such as cache data structure residence management and resource management of objects such as file handles or network sockets.

Several types of smart pointers exist. Some work with reference counting, others by assigning ownership of an object to one pointer.

History

Even though C++ popularized the concept of smart pointers, especially the reference-counted variety, the immediate predecessor of one of the languages that inspired C++'s design had reference-counted references built into the language. C++ was inspired in part by Simula67. Simula67's ancestor was Simula I. Insofar as Simula I's element is analogous to C++'s pointer without null, and insofar as Simula I's process with a dummy-statement as its activity body is analogous to C++'s struct (which itself is analogous to C. A. R. Hoare's record in then-contemporary 1960s work), Simula I had reference counted elements (i.e., pointer-expressions that house indirection) to processes (i.e., records) no later than September 1965, as shown in the quoted paragraphs below.

Processes can be referenced individually. Physically, a process reference is a pointer to an area of memory containing the data local to the process and some additional information defining its current state of execution. However, for reasons stated in the Section 2.2 process references are always indirect, through items called elements. Formally a reference to a process is the value of an expression of type element.

element values can be stored and retrieved by assignments and references to element variables and by other means.
The language contains a mechanism for making the attributes of a process accessible from the outside, i.e., from within other processes. This is called remote access- ing. A process is thus a referenceable data structure.

It is worth noticing the similarity between a process whose activity body is a dummy statement, and the record concept recently proposed by C. A. R. Hoare and N. Wirth

Because C++ borrowed Simula's approach to memory allocation—the new keyword when allocating a process/record to obtain a fresh element to that process/record—it is not surprising that C++ eventually resurrected Simula's reference-counted smart-pointer mechanism within element as well.

Features

In C++, a smart pointer is implemented as a template class that mimics, by means of operator overloading, the behaviors of a traditional (raw) pointer, (e.g. dereferencing, assignment) while providing additional memory management features.

Smart pointers can facilitate intentional programming by expressing, in the type, how the memory of the referent of the pointer will be managed. For example, if a C++ function returns a pointer, there is no way to know whether the caller should delete the memory of the referent when the caller is finished with the information.

SomeType* AmbiguousFunction();  // What should be done with the result?

Traditionally, naming conventions have been used to resolve the ambiguity, which is an error-prone, labor-intensive approach. C++11 introduced a way to ensure correct memory management in this case by declaring the function to return a unique_ptr,

std::unique_ptr<SomeType> ObviousFunction();

The declaration of the function return type as a unique_ptr makes explicit the fact that the caller takes ownership of the result, and the C++ runtime ensures that the memory will be reclaimed automatically. Before C++11, unique_ptr can be replaced with auto_ptr, which is now deprecated.

Creating new objects

To ease the allocation of a

std::shared_ptr<SomeType>

C++11 introduced:

auto s = std::make_shared<SomeType>(constructor, parameters, here);

and similarly

std::unique_ptr<some_type>

Since C++14 one can use:

auto u = std::make_unique<SomeType>(constructor, parameters, here);

It is preferred, in almost all circumstances, to use these facilities over the new keyword.

unique_ptr

C++11 introduces std::unique_ptr, defined in the header <memory>.

A unique_ptr is a container for a raw pointer, which the unique_ptr is said to own. A unique_ptr explicitly prevents copying of its contained pointer (as would happen with normal assignment), but the std::move function can be used to transfer ownership of the contained pointer to another unique_ptr. A unique_ptr cannot be copied because its copy constructor and assignment operators are explicitly deleted.

std::unique_ptr<int> p1(new int(5));
std::unique_ptr<int> p2 = p1;  // Compile error.
std::unique_ptr<int> p3 = std::move(p1);  // Transfers ownership. p3 now owns the memory and p1 is set to nullptr.

p3.reset();  // Deletes the memory.
p1.reset();  // Does nothing.

std::auto_ptr is deprecated under C++11 and completely removed from C++17. The copy constructor and assignment operators of auto_ptr do not actually copy the stored pointer. Instead, they transfer it, leaving the prior auto_ptr object empty. This was one way to implement strict ownership, so that only one auto_ptr object can own the pointer at any given time. This means that auto_ptr should not be used where copy semantics are needed. Since auto_ptr already existed with its copy semantics, it could not be upgraded to be a move-only pointer without breaking backward compatibility with existing code.

shared_ptr and weak_ptr

C++11 introduces std::shared_ptr and std::weak_ptr, defined in the header <memory>. C++11 also introduces std::make_shared (std::make_unique was introduced in C++14) to safely allocate dynamic memory in the RAII paradigm.

A shared_ptr is a container for a raw pointer. It maintains reference counting ownership of its contained pointer in cooperation with all copies of the shared_ptr. An object referenced by the contained raw pointer will be destroyed when and only when all copies of the shared_ptr have been destroyed.

std::shared_ptr<int> p0(new int(5));  // Valid, allocates 1 integer and initialize it with value 5.
std::shared_ptr<int[]> p1(new int[5]);  // Valid, allocates 5 integers.
std::shared_ptr<int[]> p2 = p1;  // Both now own the memory.

p1.reset();  // Memory still exists, due to p2.
p2.reset();  // Frees the memory, since no one else owns the memory.

A weak_ptr is a container for a raw pointer. It is created as a copy of a shared_ptr. The existence or destruction of weak_ptr copies of a shared_ptr have no effect on the shared_ptr or its other copies. After all copies of a shared_ptr have been destroyed, all weak_ptr copies become empty.

std::shared_ptr<int> p1 = std::make_shared<int>(5);
std::weak_ptr<int> wp1 {p1};  // p1 owns the memory.

{
  std::shared_ptr<int> p2 = wp1.lock();  // Now p1 and p2 own the memory.
  // p2 is initialized from a weak pointer, so you have to check if the
  // memory still exists!
  if (p2) {
    DoSomethingWith(p2);
  }
}
// p2 is destroyed. Memory is owned by p1.

p1.reset();  // Free the memory.

std::shared_ptr<int> p3 = wp1.lock(); 
// Memory is gone, so we get an empty shared_ptr.
if (p3) {  // code will not execute
  ActionThatNeedsALivePointer(p3);
}

Because the implementation of shared_ptr uses reference counting, circular references are potentially a problem. A circular shared_ptr chain can be broken by changing the code so that one of the references is a weak_ptr.

Multiple threads can safely simultaneously access different shared_ptr and weak_ptr objects that point to the same object.

The referenced object must be protected separately to ensure thread safety.

shared_ptr and weak_ptr are based on versions used by the Boost libraries. C++ Technical Report 1 (TR1) first introduced them to the standard, as general utilities, but C++11 adds more functions, in line with the Boost version.

Other types of smart pointers

There are other types of smart pointers (which are not in the C++ standard) implemented on popular C++ libraries or custom STL, some examples include hazard pointer and intrusive pointer.

Lie point symmetry

From Wikipedia, the free encyclopedia https://en.wikipedia.org/wiki/Lie_point_symmetry     ...