Forth

1 program Added 2025-10-22T09:54:04Z Model: anthropic/claude-3.5-sonnetTemp: 0.4 Evidence Report issue View issues
Aliases: FORTH
Provenance: commit 5609145213 · authored 2025-10-22T11:54:04+02:00 · model anthropic/claude-3.5-sonnet

Sources mentioning this language

9 sources · pl_id: pl/forth
LLM (this repo) · 1PldbLinguistPygmentsWikipediaEsolangHyperpolyglotRosettacodeWikidata · Q275472

Wikipedia infobox

Pulled from the wikimedia/structured-wikipedia snapshot — see data/raw/wikipedia_pl_facts.*.jsonl and pl_fact.csv for the long-table provenance.

Paradigmsconcatenative (stack-based) · procedural · reflective
Typingtypeless
Designed byCharles H. Moore
First appeared1970
Homepagehttps://forth-standard.org

Extensions claimed by this language

16 claims. Each row is one upstream assertion with its strength. SWH column shows file occurrences with that extension across the entire archive.
ExtensionSourceStrengthSWH
.4thwikidataprimary14.3K files
.fwikidataprimary3.1M files
.fbwikidataprimary5.5K files
.forthwikidataprimary4.4K files
.frtpygmentsprimary30.3K files
.fswikidataprimary2.4M files
.fthlinguistprimary30.5K files
.fthwikidataprimary30.5K files
.4thlinguistsecondary14.3K files
.flinguistsecondary3.1M files
.forlinguistsecondary149.5K files
.forthlinguistsecondary4.4K files
.frlinguistsecondary132.4K files
.frtlinguistsecondary30.3K files
.fslinguistsecondary2.4M files
.fspygmentssecondary2.4M files

Related languages

iForth (0.43)YForth (0.42)FORTH-83 (0.38)Gforth (0.38)Jorth (0.36)

LLM-contributed programs

Conway's Game of Life in Forth

Provenance: commit 5609145213 · authored 2025-10-22T11:54:04+02:00 · model anthropic/claude-3.5-sonnet · Temp 0.4
code.fs · license: Public Domain · added: 2025-10-22T09:54:04Z
variable universe 2000 allot
variable newverse 2000 allot

: xy>offset ( x y -- offset )
  50 * + ;
: offset>xy ( offset -- x y )
  50 /mod ;
: alive? ( offset -- flag )
  universe + c@ ;
: set-cell ( offset -- )
  universe + 1 swap c! ;
: clear-cell ( offset -- )
  universe + 0 swap c! ;

: count-neighbors ( offset -- neighbors )
  0 >r
  offset>xy
  -1 -1 2over + xy>offset alive? r> + >r
   0 -1 2over + xy>offset alive? r> + >r
   1 -1 2over + xy>offset alive? r> + >r
  -1  0 2over + xy>offset alive? r> + >r
   1  0 2over + xy>offset alive? r> + >r
  -1  1 2over + xy>offset alive? r> + >r
   0  1 2over + xy>offset alive? r> + >r
   1  1 2over + xy>offset alive? r> + drop
  2drop ;

: randomize ( -- )
  2000 0 do
    i universe + 2 random c!
  loop ;

: swap-universes ( -- )
  universe @ newverse @ universe ! newverse ! ;

: generation ( -- )
  2000 0 do
    i alive? if
      i count-neighbors
      dup 2 < if
        drop i newverse + 0 swap c!
      else
        dup 3 > if
          drop i newverse + 0 swap c!
        else
          drop i newverse + 1 swap c!
        then
      then
    else
      i count-neighbors 3 = if
        i newverse + 1 swap c!
      else
        i newverse + 0 swap c!
      then
    then
  loop
  swap-universes ;

Real programs from Software Heritage

1 sample mined from derived_datasets/<date>/contents/*.parquet, byte-verified against the SWH archive. Citation-grade qualified SWHIDs preserved.
brand.4th · 2771 B · ext .4th · seen 3× in SWH
via fallback
swh:1:cnt:6c7cea584ebaf581b5eaafba0d26faeb844431ff;origin=https://github.com/freebsd/freebsd-src;anchor=swh:1:rev:26a58599a09a6181e0f5abe624021865a0c23186;path=/stand/forth/brand.4th
Open in SWH · Raw bytes (SWH) · GitHub raw
Show source
\ Copyright (c) 2006-2015 Devin Teske <dteske@FreeBSD.org>
\ All rights reserved.
\ 
\ Redistribution and use in source and binary forms, with or without
\ modification, are permitted provided that the following conditions
\ are met:
\ 1. Redistributions of source code must retain the above copyright
\    notice, this list of conditions and the following disclaimer.
\ 2. Redistributions in binary form must reproduce the above copyright
\    notice, this list of conditions and the following disclaimer in the
\    documentation and/or other materials provided with the distribution.
\ 
\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\ SUCH DAMAGE.
\ 

marker task-brand.4th

variable brandX
variable brandY

\ Initialize brand placement to defaults
2 brandX !
1 brandY !

\ This function draws any number of company brands at (loader_brand_x,
\ loader_brand_y) if defined, or (2,1) (top-left). To choose your brand, set
\ the variable `loader_brand' to the respective brand name.
\ 
\ NOTE: Each is defined as a brand function in /boot/brand-${loader_brand}.4th
\ NOTE: If `/boot/brand-${loader_brand}.4th' does not exist or does not define
\       a `brand' function, no brand is drawn.
\ 
: draw-brand ( -- ) \ at (loader_brand_x,loader_brand_y), else (2,1)

	s" loader_brand_x" getenv dup -1 <> if
		?number 1 = if brandX ! then
	else drop then
 	s" loader_brand_y" getenv dup -1 <> if
 		?number 1 = if brandY ! then
 	else drop then

	\ If `brand' is defined, execute it
	s" brand" sfind ( -- xt|0 bool ) if
		brandX @ brandY @ rot execute
	else
		\ Not defined; try-include desired brand file
		drop ( xt = 0 ) \ cruft
		s" loader_brand" getenv dup -1 = over 0= or if
			dup 0= if 2drop else drop then \ getenv result unused
			s" try-include /boot/brand-fbsd.4th"
		else
			2drop ( c-addr/u -- ) \ getenv result unused
			s" try-include /boot/brand-${loader_brand}.4th"
		then
		evaluate
		1 spaces

		\ Execute `brand' if defined now
		s" brand" sfind if
			brandX @ brandY @ rot execute
		else drop then
	then
;

: draw-brand
	['] draw-brand console-iterate
;

Disambiguation rules

Linguist heuristic rules that predict this language when one of its claimed extensions is shared with another.
RuleExtKindPredicates (truncated)
h/linguist/.f/0.fpredicates[{"kind": "any", "regexes": ["^: "]}]
h/linguist/.fr/0.frpredicates[{"kind": "any", "regexes": ["^(: |also |new-device|previous )"]}]
h/linguist/.for/0.forpredicates[{"kind": "any", "regexes": ["^: "]}]
h/linguist/.fs/0.fspredicates[{"kind": "any", "regexes": ["^(: |new-device)"]}]

Contribute — propose a file extension

Tell us where to find evidence about Forth (mapped to pl/forth). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Forth/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← forte-4gl Forth (programming language) →