C--

C--
Paradigmimperative
Designed bySimon Peyton Jones and Norman Ramsey
First appeared1998
Typing disciplinestatic, weak
Websitewww.cs.tufts.edu/~nr/c--/
Influenced by
C

C-- (pronounced C minus minus) is a C-like programming language, designed to be generated mainly by compilers for high-level languages rather than written by human programmers. It was created by functional programming researchers Simon Peyton Jones and Norman Ramsey. Unlike many other intermediate languages, it is represented in plain ASCII text, not bytecode or another binary format.[1][2]

There are two main branches:

Design

C-- is a "portable assembly language",[6] designed to ease the implementation of compilers that produce high-quality machine code.[7] This is done by delegating low-level code-generation and program optimization to a C-- compiler. The language's syntax borrows heavily from C while omitting or changing standard C features such as variadic functions, pointer syntax, and aspects of C's type system, because they hamper essential features of C-- and ease of code-generation.

The name of the language is an in-joke, indicating that C-- is a reduced form of C, in the same way that "C++" was chosen to connote an improved version of C. (In C, -- and ++ mean "decrement" and "increment", respectively.)[8]

Work on C-- began in the late 1990s. Since writing a custom code generator is a challenge in itself, and the compiler backends available to researchers at that time were complex and poorly documented, several projects had written compilers which generated C code (for instance, the original Modula-3 compiler). However, C is a poor choice for functional languages: it does not guarantee tail-call optimization, or support accurate garbage collection or efficient exception handling. C-- is a tightly-defined simpler alternative to C which supports all of these. Its most innovative feature is a run-time interface which allows writing of portable garbage collectors, exception handling systems and other run-time features which work with any C-- compiler.

The first version of C-- was released in April 1998 as a MSRA paper,[1] accompanied by a January 1999 paper on garbage collection.[2] A revised manual was posted in HTML form in May 1999.[9] Two sets of major changes proposed in 2000 by Norman Ramsey ("Proposed Changes") and Christian Lindig ("A New Grammar") led to C-- version 2, which was finalized around 2004 and officially released in 2005.[3]

Type system

The C-- type system is designed to reflect constraints imposed by hardware rather than conventions imposed by higher-level languages. A value stored in a register or memory may have only one type: bit-vector. However, bit-vector is a polymorphic type which comes in several widths, e.g. bits8, bits32, or bits64. A separate 32-or-64 bit family of floating-point types is supported. In addition to the bit-vector type, C-- provides a boolean type bool, which can be computed by expressions and used for control flow but cannot be stored in a register or memory. As in an assembly language, any higher type discipline, such as distinctions between signed, unsigned, float, and pointer, is imposed by the C-- operators or other syntactic constructs. C-- is not type-checked, nor does it enforce or check the calling convention.[3]: 28 

C-- version 2 removes the distinction between bit-vector and floating-point types. These types can be annotated with a string "kind" tag to distinguish, among other things, a variable's integer vs float typing and its storage behavior (global or local). The former is useful on targets that have separate registers for integer and floating-point values. Special types for pointers and the native word were introduced, although they are mapped to a bit-vector with a target-dependent length.[3]: 10 

Example code

The following C-- code calculates the sum and product of integers 1 through n[10] (n is received as an argument). It demonstrates two language features:

  • Procedures can return multiple results.
  • Tail recursion is explicitly requested with the "jump" keyword.
/* Tail recursion */
export sp;
sp( bits32 n ) {
  jump sp_help( n, 1, 1 );
}

sp_help( bits32 n, bits32 s, bits32 p ) {
  if n==1 {
      return( s, p );
  } else {
      jump sp_help( n-1, s+n, p*n );
  }
}

Implementations

The specification page of C-- lists a few implementations of C--. The "most actively developed" compiler, Quick C--, was abandoned in 2013.[11]

Haskell

Some developers of C--, including Simon Peyton Jones, João Dias, and Norman Ramsey, work or have worked on GHC, whose development has led to extensions in the C-- language, forming the Cmm dialect which uses the C preprocessor for ergonomics.[4][12]

GHC backends are responsible for further transforming C-- into executable code, via LLVM IR, slow C, or directly through the built-in native backend.[13][14][15] Despite the original intention, GHC does perform many of its generic optimizations on C--. As with other compiler IRs, the C-- representation can be dumped for debugging.[16] Target-specific optimizations are performed later by the backend.

Processing systems

As of 2018, most processing systems are not maintained, nor is their source code released.

  • Quick C-- is a compiler developed by The Quick C-- Team. It compiles version 2 of C-- code to Intel x86 Linux machine code. Compilation to machine code for other platforms is available as an experimental feature. Previously, Quick C-- was developed in parallel with the evolution of the C-- language specification, but the project was archived in 2019 on GitHub and development has ceased, though the source code is available there.
  • cmmc is a C-- compiler implemented in the ML programming language by Fermin Reig. It generates machine code for Alpha, Sparc, and x86 architectures.[17]
  • Trampoline C-- Compiler is a C-- to C transpiler developed by Sergei Egorov in May 1999. It translates C-- code into C code, allowing it to be compiled using standard C compilers.
  • The Oregon Graduate Institute's C-- compiler (OGI C-- Compiler) is the earliest prototype C-- compiler, developed in 1997 using the ML programming language. Maintenance of the OGI C-- Compiler was discontinued once development of Quick C-- began.

See also

References

  1. ^ a b Nordin, Thomas; Jones, Simon Peyton; Iglesias, Pablo Nogueira; Oliva, Dino (1998-04-23). "The C– Language Reference Manual". {{cite journal}}: Cite journal requires |journal= (help)
  2. ^ a b Reig, Fermin; Ramsey, Norman; Jones, Simon Peyton (1999-01-01). "C–: a portable assembly language that supports garbage collection": 1–28. {{cite journal}}: Cite journal requires |journal= (help)
  3. ^ a b c d Ramsey, Norman; Jones, Simon Peyton. "The C-- Language Specification, Version 2.0" (PDF). Retrieved 11 December 2019.
  4. ^ a b GHC Commentary: What the hell is a .cmm file?
  5. ^ "An improved LLVM backend". April 2019.
  6. ^ Oliva, Dino; Nordin, T.; Peyton Jones, Simon (1997-01-01). "C-: A Portable Assembly Language". Proceedings of the 1997 Workshop on Implementing Functional Languages – via Microsoft.
  7. ^ Jones, Simon Peyton; Nordin, Thomas; Oliva, Dino (1998). Clack, Chris; Hammond, Kevin; Davie, Tony (eds.). "C--: A portable assembly language". Implementation of Functional Languages. Berlin, Heidelberg: Springer: 1–19. doi:10.1007/BFb0055421. ISBN 978-3-540-68528-9.
  8. ^ "Increment And Decrement Operators In C With Precedence". unstop.com. Retrieved 2024-06-20.
  9. ^ Nordin, Thomas; Jones, Simon Peyton; Iglesias, Pablo Nogueira; Oliva, Dino (1999-05-23). "The C– Language Reference Manual".
  10. ^ Ramsey, Norman; Jones, Simon Peyton; Lindig, Christian (2005-02-23), The C-- Language Specification, version 2.0 (CVS Revision 1.128) (PDF), p. 7, retrieved 2023-06-22
  11. ^ "C-- Downloads". www.cs.tufts.edu. Retrieved 11 December 2019.
  12. ^ "5.10. GHC Backends — Glasgow Haskell Compiler 9.8.1 User's Guide". downloads.haskell.org. Retrieved 2024-06-20.
  13. ^ GHC Backends
  14. ^ "Opinion piece on GHC backends". andreaspk.github.io. August 25, 2019. Retrieved 2024-06-20.
  15. ^ "Using the Glasgow Haskell Compiler (GHC)". ProgDoer. Retrieved 2024-06-20.
  16. ^ Debugging compilers with optimization fuel
  17. ^ "C-- Downloads". www.cs.tufts.edu. Retrieved 2024-06-20.

Read other articles:

Chapter of the Judeo-Christian Bible Zechariah 14← chapter 13Malachi 1 →Book of Zechariah (13:9-14:21) in Latin in Codex Gigas, made around 13th century.BookBook of ZechariahCategoryNevi'imChristian Bible partOld TestamentOrder in the Christian part38 Zechariah 14 is the fourteenth (and the final) chapter in the Book of Zechariah in the Hebrew Bible and the Old Testament of the Christian Bible.[1][2][3] This book contains the prophecies attributed to the ...

 

Cần ThơCentrally-governed city LambangMotto: Caritas – Gaudium – PaxLetak Cần ThơNegara VietnamLuas • Total1.389,6 km2 (5,365 sq mi)Populasi (2004) • Total1.121.000 • Kepadatan807/km2 (2,090/sq mi)Situs webhttp://www.cantho.gov.vn Cần Thơ adalah sebuah kota di sebelah barat daya Vietnam. Kota ini merupakan kota terbesar di kawasan Delta Sungai Mekong, 169 kilometer barat kota Ho Chi Minh, Vietnam. Penduduknya ...

 

RinchinbalKaisar Ningzong dari Yuan 元寧宗Khagan ke-14 dari Kekaisaran Mongol(Nominal karena pembagian kekaisaran)Kaisar Tiongkok(Kaisar Dinasti Yuan ke-10)Portrait of Rinchinbal Khan, Emperor Ningzong of YuanKaisar Dinasti YuanBerkuasa23 Oktober 1332 – 14 Desember 1332Penobatan23 Oktober 1332PendahuluJayaatu Khan Tugh TemürPenerusUkhaghatu Khan Toghon TemürInformasi pribadiKelahiran1 Mei 1326Kematian14 Desember 1332(1332-12-14) (umur 6)Dadu, Yuan TiongkokWangsaBorjiginNama lengka...

1987 American crime film directed by Brian De Palma The UntouchablesTheatrical release posterDirected byBrian De PalmaScreenplay byDavid MametBased onThe Untouchablesby Eliot NessOscar FraleyProduced byArt LinsonStarring Kevin Costner Charles Martin Smith Andy García Robert De Niro Sean Connery CinematographyStephen H. BurumEdited by Gerald B. Greenberg Bill Pankow Music byEnnio MorriconeDistributed byParamount PicturesRelease dates June 2, 1987 (1987-06-02) (New York City...

 

Elements and compounds that are readily vaporized For other uses, see Volatile (disambiguation). This article relies largely or entirely on a single source. Relevant discussion may be found on the talk page. Please help improve this article by introducing citations to additional sources.Find sources: Volatile astrogeology – news · newspapers · books · scholar · JSTOR (October 2011) Volatiles are the group of chemical elements and chemical compound...

 

Ritratto di Mircea Eliade (1907-1986, particolare di un ritratto pubblicato su un francobollo moldavo). Mircea Eliade (AFI: [ˈmirt͡ʃe̯a eliˈade]; Bucarest, 13 marzo 1907 – Chicago, 22 aprile 1986) è stato uno storico delle religioni, antropologo, scrittore, filosofo, mitografo, saggista romeno. Uomo di grande cultura, assiduo viaggiatore, parlava e scriveva correntemente diverse lingue: rumeno, francese, tedesco, italiano, inglese, ebraico, persiano e sanscrito. Indice 1 Biografia 2 L...

Kacamata makasar Status konservasi Risiko Rendah  (IUCN 3.1)[1] Klasifikasi ilmiah Kerajaan: Animalia Filum: Chordata Kelas: Aves Ordo: Passeriformes Famili: Zosteropidae Genus: Zosterops Spesies: Z. anomalus Nama binomial Zosterops anomalusMeyer & Wiglesworth, 1896 Kacamata makasar adalah spesies burung kacamata dalam famili Zosteropidae. Burung ini endemik di Pulau Sulawesi dan penyebarannya hanya terbatas di Sulawesi Selatan.[2] Referensi ^ BirdLife Internati...

 

Village in Kyushu, JapanTonaki 渡名喜村TunachiVillageTonaki Village Office FlagLocation of Tonaki in Okinawa PrefectureTonakiLocation in JapanCoordinates: 26°22′20″N 127°08′28″E / 26.37222°N 127.14111°E / 26.37222; 127.14111CountryJapanRegionKyushuPrefectureOkinawa PrefectureDistrictShimajiriArea • Total3.74 km2 (1.44 sq mi)Population (2022) • Total334 • Density89/km2 (230/sq mi)Time zoneUTC+0...

 

Capital city of Bahia, Brazil Municipality in Northeast, BrazilSalvadorMunicipalityMunicipality of Salvador Município de SalvadorSkyline of Salvador from BarraBarra LighthousePelourinhoMonument to the Second of JulyHistoric CenterLacerda ElevatorPanoramic view of the Vitória neighborhood FlagSealNickname(s): Roma Negra (Black Rome) and SoterópolisMotto(s): Sic illa ad arcam reversa est (Latin)So she returned to the arkLocation of Salvador in the State of BahiaSalvadorLocation in ...

Untuk ibukota provinsi Herat, lihat Herat (kota). Kota Herat Herāt adalah sebuah provinsi yang terletak di Afganistan barat, dan beribu kota di kota Herat. Kota Herat terletak di lembah Hari Rud. Populasi kota ini berjumlah 349.000.[1] Herat secara tradisional terkenal karena minuman anggurnya. Herat juga merupakan kota tua dengan banyak bangunan bersejarah, walaupun beberapa telah rusak karena berbagai konflik militer, contohnya Perang Soviet-Afganistan dan Perang Saudara Afganistan...

 

Bintang RadioNama lainBintang Radio IndonesiaBintang Radio dan TelevisiBintang Radio Indonesia dan ASEANGenreAjang pencarian bakatNegara IndonesiaStasiun utamaRRITVRI (1974-?)PembuatMaladiTanggal mengudara1951 (1951) sampai sekarangJumlah episodeBervariasi Bintang Radio (atau Bintang Radio Indonesia) adalah sebuah acara pencarian bakat menyanyi yang diselenggarakan dan disiarkan oleh RRI. Acara ini pertama kali diselenggarakan pada tahun 1951 untuk memperingati Hari Radio (yang bertepata...

 

SMA Sedes Sapientiae JambuInformasiDidirikan1 Juli 1989JenisSwastaAkreditasiA [1]Nomor Pokok Sekolah Nasional20320392Kepala SekolahSr. M. Coleta, OSF, M.Pd.Jumlah kelas4 kelas setiap tingkatJurusan atau peminatanIPA dan IPSRentang kelasX, XI IPA, XI IPS, XII IPA, XII IPSKurikulumKurikulum 2013 Kurikulum MerdekaJumlah siswa339 siswaStatusAkreditasi A‎NEM terendah- (-)NEM tertinggi- (-)Nilai masuk rata-rata- (-)AlamatLokasiJl. Raya Ambarawa - Magelang km. 10 Bedono, Jaw...

Jalanan utama di Shanksville Shanksville ialah sebuah borough di Somerset County, Pennsylvania, Amerika Serikat. Shanksville berpenduduk 245 jiwa pada tahun 2000. Nama Shanksville menyeruak di media internasional akibat serangan 11 September 2001, di mana United Airlines Penerbangan 93 jatuh di sini. Sebuah monumen akan dibangun di sini, dan pembangunannya akan selesai pada tahun 2011. Geografi Menurut United States Census Bureau, luas daerah ini mencapai 0,5 km², yang seluruhnya berupa...

 

Spanish politician (born 1950) In this Spanish name, the first or paternal surname is Fernández and the second or maternal family name is Díaz. Jorge Fernández DíazMinister of the InteriorIn office22 December 2011 – 4 November 2016MonarchsJuan Carlos I (2011–2014)Felipe VI (2014–2016)Prime MinisterMariano RajoyPreceded byAntonio Camacho VizcaínoSucceeded byJuan Ignacio ZoidoMember of the Congress of DeputiesIn office28 October 1989 – 21 May 2019Constitue...

 

  Eudicotiledóneas o tricolpadas Primaveras (Primula)TaxonomíaReino: PlantaeDivisión: Angiospermae(sin rango): MesangiospermaeClase: EudicotyledoneaeDoyle & Hotton 1991[1]​clados (órdenes) Ranunculales Sabiales Proteales Trochodendrales Buxales Gunneridae o eudicotas nucleares: Gunnerales Pentapetalae Berberidopsidales Dilleniales Caryophyllales Santalales Saxifragales Vitales Rósidas con unos 16 órdenes Astéridas con unos 10 órdenes Sinonimia Tricolpatae (Donoghue &...

Geographical ecclesiastical structure for Eastern Catholic communities Part of a series on theCanon law of theCatholic Church Ius vigens (current law) 1983 Code of Canon Law Omnium in mentem Magnum principium Code of Canons of the Eastern Churches Ad tuendam fidem Ex corde Ecclesiae Indulgentiarum Doctrina Praedicate evangelium Veritatis gaudium Custom Matrimonial nullity trial reforms of Pope Francis Documents of the Second Vatican Council Christus Dominus Lumen gentium Optatam totius Orient...

 

American TV series or program Villa ParaísoGenreTelenovelaCreated byAlex HadadDirected byErrol FalcónStarringXimena DuqueDavid ChocarroSilvana AriasRicardo ChávezCountry of originUnited StatesOriginal languageSpanishNo. of seasons1No. of episodes20ProductionExecutive producerAlina BérrizCamera setupMulti-cameraOriginal releaseNetworkTelemundo[1]ReleaseOctober 6 (2014-10-06) –October 31, 2014 (2014-10-31)[2] Villa Paraíso is an American telenovela produce...

 

رابطة كيميائية المناهضة[1] أو الضادة[1] أو معاكس المستقبلات أو الحاجب[2] أو المُضادّ[2] (بالإنجليزية: Antagonist)‏ مركب كيميائي قادر على الارتباط بالمستقبلات الدوائية دون إثارة أي تنبيه في هذه المستقبلات ومنع المحفزات الدوائية من الارتباط بهذه المستقبلات إما تنا�...

جمعية كشافة النيجر الدولة النيجر  تعديل مصدري - تعديل   جمعية كشافة النيجر هي المنظمة الكشفية الوطنية في النيجر.[1][2] وقد تأسست في عام 1993 وأصبحت عضوا في المنظمة العالمية للحركة الكشفية في عام 1996. وتعتبر الجمعية مختلطة ولديها 3202 عضوا اعتبارا من عام 2011. روابط خارج�...

 

Species of moth Asura fulvimarginata Scientific classification Domain: Eukaryota Kingdom: Animalia Phylum: Arthropoda Class: Insecta Order: Lepidoptera Superfamily: Noctuoidea Family: Erebidae Subfamily: Arctiinae Genus: Asura Species: A. fulvimarginata Binomial name Asura fulvimarginataHampson, 1904 Asura fulvimarginata is a moth of the family Erebidae. It is found in India.[1] References Wikimedia Commons has media related to Asura fulvimarginata. ^ Beccaloni, G.; Scoble, M.; K...