Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
category:
- Simple
from: http://rosettacode.org/wiki/Naming_conventions
note: Programming environment operations

View file

@ -0,0 +1,22 @@
Many languages have naming conventions regarding the identifiers used in the language, its libraries, and programs written in the language. Such conventions, which may be classified as ''de facto'' or ''de jure'' depending on how they are enforced,
often take the form of rules regarding prefixes, suffixes, and the use of upper-case and lower-case characters.
The naming conventions are sometimes a bit haphazard, especially if the language and/or library has gone through periods of evolution. (In this case: give a brief example and description.)
Document (with simple examples where possible) the evolution and current status of these naming conventions.
For example, name conventions for:
* Procedure and operator names. (Intrinsic or external)
* Class, Subclass and instance names.
* Built-in versus libraries names.
<br>
If possible, indicate where the naming conventions are implicit, explicit, mandatory or discretionary.
Any tools that enforced the the naming conventions.
Any cases where the naming convention as commonly violated.
If possible, indicate where the convention is used to hint at other issues. For example the C standard library uses a prefix of "_" to "hide" raw Operating System calls from the non systems-programmer, whereas Python embeds member functions in between "__" to make a member function "private".
;See also:
* Wikipedia: [[wp:Naming convention (programming)|Naming convention (programming)]]
<br><br>

View file

@ -0,0 +1,7 @@
MODE ℵ SIMPLEOUT = UNION (≮INT≯, ≮REAL≯, ≮COMPL≯, BOOL, ≮BITS≯, CHAR, [ ] CHAR);
PROC cos = ( REAL x) REAL: ¢ a real value close to the cosine of 'x' ¢;
PROC complex cos = ( COMPL z) COMPL: ¢ a complex value close to the cosine of 'z' ¢;
PROC arccos = ( REAL x) REAL: ¢ if ABS x ≤ 1, a real value close
to the inverse cosine of 'x', 0 ≤ arccos (x) ≤ pi ¢;

View file

@ -0,0 +1,6 @@
PROC long long cos = (LONG LONG REAL x) LONG LONG REAL: ¢ a real value close to the cosine of 'x' ¢;
PROC long long complex cos = (LONG LONG COMPL z) LONG LONG COMPL: ¢ a complex value close to the cosine of 'z' ¢;
PROC long long arccos = (LONG LONG REAL x) LONG LONG REAL: ¢ if ABS x ≤ 1, a real value close
to the inverse cosine of 'x', 0 ≤ arccos (x) ≤ pi ¢;

View file

@ -0,0 +1,8 @@
'pr' quote 'pr'
'mode' 'xint' = 'int';
'xint' sum sq:=0;
'for' i 'while'
sum sq≠70×70
'do'
sum sq+:=i↑2
'od'

View file

@ -0,0 +1,8 @@
.PR UPPER .PR
MODE XINT = INT;
XINT sum sq:=0;
FOR i WHILE
sum sq/=70*70
DO
sum sq+:=i**2
OD

View file

@ -0,0 +1,8 @@
.PR POINT .PR
.MODE .XINT = .INT;
.XINT SUM SQ:=0;
.FOR I .WHILE
SUM SQ .NE 70*70
.DO
SUM SQ .PLUSAB I .UP 2
.OD

View file

@ -0,0 +1,8 @@
.PR RES .PR
mode .xint = int;
.xint sum sq:=0;
for i while
sum sq≠70×70
do
sum sq+:=i↑2
od

View file

@ -0,0 +1 @@
variables-are-often-lower-case-and-seperated-like-this-one

View file

@ -0,0 +1,46 @@
# Field names begin with $ so $1 is the first field, $2 the second and $NF the
# last. $0 references the entire input record.
#
# Function and variable names are case sensitive and begin with an alphabetic
# character or underscore followed by any number of: a-z, A-Z, 0-9, _
#
# The awk language is type less; variables are either string or number
# depending upon usage. Variables can be coerced to string by concatenating ""
# or to number by adding zero. For example:
# str = x ""
# num = x + 0
#
# Below are the names of the built-in functions, built-in variables and other
# reserved words in the awk language separated into categories. Also shown are
# the names of gawk's enhancements.
#
# patterns:
# BEGIN END
# BEGINFILE ENDFILE (gawk)
# actions:
# break continue delete do else exit for if in next return while
# case default switch (gawk)
# arithmetic functions:
# atan2 cos exp int log rand sin sqrt srand
# bit manipulation functions:
# and compl lshift or rshift xor (gawk)
# i18n functions:
# bindtextdomain dcgettext dcngettext (gawk)
# string functions:
# gsub index length match split sprintf sub substr tolower toupper
# asort asorti gensub patsplit strtonum (gawk)
# time functions:
# mktime strftime systime (gawk)
# miscellaneous functions:
# isarray (gawk)
# variables:
# ARGC ARGV CONVFMT ENVIRON FILENAME FNR FS NF NR OFMT OFS ORS RLENGTH RS RSTART SUBSEP
# ARGIND BINMODE ERRNO FIELDWIDTHS FPAT FUNCTAB IGNORECASE LINT PREC PROCINFO ROUNDMODE RT SYMTAB TEXTDOMAIN (gawk)
# function definition:
# func function
# input-output:
# close fflush getline nextfile print printf system
# pre-processor directives:
# @include @load (gawk)
# special files:
# /dev/stdin /dev/stdout /dev/error

View file

@ -0,0 +1 @@
DEF PROC_foo(bar, baz$(), quux%, RETURN fred%, RETURN jim%)

View file

@ -0,0 +1,10 @@
# Subjects (arrays, numbers, characters, etc) start with a lowercase letter:
var3
arr1,2
# Functions start with an uppercase letter:
Fun{𝕨+𝕩}
Avg+´÷
# 1-modifiers start with an underscore and do not end with an underscore:
_mod{𝔽𝕩}
# 2-modifiers must start and end with an underscore:
_mod2_{𝔾𝕨𝔽𝕩}

View file

@ -0,0 +1,17 @@
public enum Planet {
Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune
}
[Flags]
public enum Days {
None = 0,
Sunday = 1,
Monday = 2,
Tuesday = 4,
Wednesday = 8,
Thursday = 16,
Friday = 32,
Saturday = 64,
Workdays = Monday | Tuesday | Wednesday | Thursday | Friday
AllWeek = Sunday | Saturday | Workdays
}

View file

@ -0,0 +1 @@
Dictionary<TKey, TValue>

View file

@ -0,0 +1 @@
IPrinter<T>

View file

@ -0,0 +1 @@
O_RDONLY, O_WRONLY, or O_RDWR. O_CREAT, O_EXCL, O_NOCTTY, and O_TRUNC

View file

@ -0,0 +1,2 @@
extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s) __wur;

View file

@ -0,0 +1,4 @@
#include <math.h>
double cos(double x);
float cosf(float x);
long double cosl(long double x);

View file

@ -0,0 +1,4 @@
#include <complex.h>
double complex ccos(double complex z);
float complex ccosf(float complex z);
long double complex ccosl(long double complex z);

View file

@ -0,0 +1,13 @@
#include <stdio.h>
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, ...);
#include <stdarg.h>
int vprintf(const char *format, va_list ap);
int vfprintf(FILE *stream, const char *format, va_list ap);
int vsprintf(char *str, const char *format, va_list ap);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);

View file

@ -0,0 +1,34 @@
(defvar *language* :en
"The language to use for messages (defaults to English)")
(defmacro with-language ((language) &body body)
"Locally binds *LANGUAGE* to LANGUAGE"
`(let ((*language* ,language))
,@body))
(defgeneric complain% (language about)
;; The % indicates this is an “internal” implementation detail.
(:method ((language (eql :en)) (about (eql :weather)))
"It's too cold in winter"))
(defun complain (about)
"Complain about something indicated by ABOUT"
(princ (complain% *language* about) *error-output*)
(terpri *error-output*)
(finish-output *error-output*)
nil)
(defmethod complain% ((language (eql :es)) (about (eql :weather)))
"Hace demasiado frío en invierno")
(complain :weather)
(with-language (:es)
(complain :weather))
(complain :weather)
It's too cold in winter
Hace demasiado frío en invierno
It's too cold in winter

View file

@ -0,0 +1,7 @@
(defun do-something (argument &key ((secret-arg secret) "default"))
(format t "Argument is ~a, secret is ~a" argument secret))
;; Normal caller
(do-something "Foo")
;; Special caller:
(do-something "Foo" 'secret-arg "Bar")

View file

@ -0,0 +1,9 @@
#+sbcl
(defun user-name+home-phone (user-id)
"Returns the real name and home phone for user with ID USER-ID as multiple values.
Reads the GECOS field. SBCL+Linux-specific, probably."
(destructuring-bind (real-name office office-phone home-phone &rest _)
(uiop:split-string (sb-posix:passwd-gecos (sb-posix:getpwuid user-id))
:separator ",")
(declare (ignore office office-phone _))
(values real-name home-phone)))

View file

@ -0,0 +1,6 @@
var xs = Array.Empty(10)
var ys = Array(1, 2, 3)
var str = xs.ToString()
type Maybe = Some(x) or None()
var x = Maybe.Some(42)

View file

@ -0,0 +1,23 @@
// a module name is the name of the app or library, followed by the domain name of the organization;
// alternatively, a "throw-away" module can have a simple name, like "TestApp"
module shop.acme.com {
// other than modules, all type and class names (including enum values) use upper CamelCase;
const Point(Int x, Int y);
enum Color {Red, Green, Blue}
interface Callback {
// variables, properties, methods, and functions using lower camelCase
Boolean active;
void onEvent(String event);
void onError(Exception e);
}
// constants use upper CamelCase, or in some cases, UPPER_SNAKE_CASE
String DefaultLogin = "guest";
Int MAX_QUANTITY = 100;
// type variables are named for their meanings, and use upper CamelCase
interface Bag<Element>
extends Iterable<Element> {
void add(Element e);
}
}

View file

@ -0,0 +1,16 @@
\ fetch and store usage examples
VARIABLE MYINT1
VARIABLE MYINT2
2VARIABLE DOUBLE1
2VARIABLE DOUBLE2
MYINT1 @ MYINT2 !
MYDOUBLE 2@ MYDOUBLE 2!
\ record example using this convention
1000000 RECORDS PERSONEL
1 PERSONEL RECORD@ \ read Record 1 and put pointer on data stack
HR_RECORD 992 PERSONEL RECORD! \ store HR_RECORD

View file

@ -0,0 +1,10 @@
\ buffer is a word that creates a named memory space and ends in a ':'
: buffer: ( bytes -- ) create allot ;
hex 100 buffer: mybuffer \ buffer: creates a new WORD in the dictionary call mybuff
\ if object programming extensions are added to Forth they could look like this
class: myclass <super integer
m: get @ ;m \ create the methods with m: ;m
m: put ! ;m
m: clear 0 swap ! ;m
;class

View file

@ -0,0 +1 @@
IMPLICIT REAL(A-H,O-Z), INTEGER(I-M)

View file

@ -0,0 +1,3 @@
DO 999 I=1 10
PRINT *,I
999 CONTINUE

View file

@ -0,0 +1 @@
IMPLICIT NONE

View file

@ -0,0 +1 @@
IMPLICIT LOGICAL

View file

@ -0,0 +1,31 @@
// version 1.0.6
const val SOLAR_DIAMETER = 864938
enum class Planet { MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE, PLUTO } // Yeah, Pluto!
class Star(val name: String) {
fun showDiameter() {
println("The diameter of the $name is ${"%,d".format(SOLAR_DIAMETER)} miles")
}
}
class SolarSystem(val star: Star) {
private val planets = mutableListOf<Planet>() // some people might prefer _planets
init {
for (planet in Planet.values()) planets.add(planet)
}
fun listPlanets() {
println(planets)
}
}
fun main(args: Array<String>) {
val sun = Star("sun")
val ss = SolarSystem(sun)
sun.showDiameter()
println("\nIts planetary system comprises : ")
ss.listPlanets()
}

View file

@ -0,0 +1,41 @@
Naming conventions
1) global names
- a name is a group of any character except space and curly braces {}
for instance "add", "+", "123", "()", "a.b.c", "...", ...
- but giving a variable the name of the 9 special forms (keywords)
["lambda", "def", "if", "let", "quote", "macro", "script", "style", "require"]
or of one of the more than 170 primitives
["div", ..., "+", ..., "cons", ..., A.new, A.first, A.rest, ..., long_add, ...]
is possible but is obviously strongly discouraged.
- when a function calls an helper function, it's better to prefix the helper function's name
with the calling function's name. For instance the function "fibonacci" sets
some initializations and calls the recursive part "fibonacci.rec".
- functions organized into sets (libraries) should be named with a common prefix.
For instance the set of functions working on complex numbers [ "C.new", "C.x", "C.y", "C.+", "C.*", ...],
suggesting object-oriented programming.
2) local names
Consider this example:
{def add {lambda {:a :b} :a+:b is equal to {+ :a :b}}}
-> add
{add 3 4}
-> 3+4 is equal to 7
When the add function is called the occurences of arguments {:a :b} are replaced by the given values, [3 4],
in the body of the function ":a+:b is equal to {+ :a :b}", leading to "3+4 is equal to {+ 3 4}" and finally
to "3+4 is equal to 7". Note that the character "a" inside the word "equal" has not been replaced.
So generally speaking:
- inside a function local defined arguments must be prefixed by a colon, ":",
- they must have a null intersection. For instance this arguments list {:a1 :a2} is valid
because the intersection of :a1 and :a2 is null, but this one {:a :a1} is not,
because the intersection of :a and :a1 is :a.
- an alternative could be to prefix and postfix names, say :a: and :a1: which have a null intersection.
It's a matter of choice let to the coder. In all cases naming must be done with the utmost care.

View file

@ -0,0 +1,8 @@
local DISTANCE_MAXIMUM = 1
local distance_to_target = 0
local function distanceToTarget() end
local function TargetFactory() end
for _,v in ipairs(table) do
print(v)
end

View file

@ -0,0 +1,34 @@
Class Alfa$ {
Private:
myValue$
Public:
Set {
Read .myValue$
}
Value {
=.myValue$
}
Module Doit {
Function TwoChars$(A$) {
=Left$(Left$(a$,1)+Right$(a$,1)+"??",2)
}
Print TwoChars$(.myValue$)
Dim A$(3)
A$(0)="zero","one","two"
Print A$(1)
k$=Lambda$ A$() (x) -> {
if x>0 and x<3 then {=A$(x)} else =A$(0)
}
Print k$(2)
Dim A$()
Print Len(A$())=0
Print k$(2)="two"
}
}
A$=Alfa$()
Module CheckIt(&B$) {
Input "name:", B$
B.Doit
}
Checkit &A$
Print A$

View file

@ -0,0 +1,9 @@
# Constants can start with either a lower case or upper case letter.
const aConstant = 42
const FooBar = 4.2
var aVariable = "Meep" # Variables must start with a lowercase letter.
# Types must start with an uppercase letter.
type
FooBar = object

View file

@ -0,0 +1,6 @@
type
PathComponent = enum
pcDir
pcLinkToDir
pcFile
pcLinkToFile

View file

@ -0,0 +1,6 @@
type
PathComponent {.pure.} = enum
Dir
LinkToDir
File
LinkToFile

View file

@ -0,0 +1,10 @@
def *'#-? "Hello world" print enddef
*'#-? nl
10 var +{&
+{& print
5 var + /# redefine + to variable with value 5. Aritchmetic word is missing #/
+ print

View file

@ -0,0 +1 @@
w=length(abc)

View file

@ -0,0 +1,6 @@
s= 'abcd'
say "length(s) =" length(s) /* ──► 1000 */
say "'LENGTH'(s) =" 'LENGTH'(s) /* ──► 4 */
exit
length: return 1000

View file

@ -0,0 +1,4 @@
#lang racket
render-game-state
send-message-to-client
traverse-forest

View file

@ -0,0 +1,7 @@
#lang racket
(string-ref "1234" 2)
(string-length "123")
(string-append "12" "34")
;exceptions:
(append (list 1 2) (list 3 4))
(unbox (box 7))

View file

@ -0,0 +1,6 @@
#lang racket
(struct pair (x y) #:transparent #:mutable)
(define p (pair 1 2))
(pair-x p) ; ==> 1
(set-pair-y! p 3)
p ; ==> (pair 1 3)

View file

@ -0,0 +1,3 @@
#lang racket
(list->vector '(1 2 3 4))
(number->string 7)

View file

@ -0,0 +1,15 @@
;predicates and boolean-valued functions: ?
(boolean? 5)
(list? "123")
;setters and field mutators: !
(set! x 5)
(vector-set! v 2 "x")
; classes: %
game-state%
button-snip%
;interfaces: <%>;
dc<%>;
font-name-directory<%>

View file

@ -0,0 +1,5 @@
test_variable = [1, 9, 8, 3]
test_variable.sort # => [1, 3, 8, 9]
test_variable # => [1, 9, 8, 3]
test_variable.sort! # => [1, 3, 8, 9]
test_variable # => [1, 3, 8, 9]

View file

@ -0,0 +1,47 @@
# Global variable
$number_of_continents = 7
module Banking
# Module constants for semantic versioning
VERSION = '1.0.0.1'
class BankAccount
attr_accessor :first_name, :last_name
attr_reader :account_number
@@ATM_FEE = 3.75
@@adiministrator_password = 'secret'
# The class's constructor
def initialize(first_name, last_name, account_number)
@first_name = first_name
@last_name = last_name
@account_number = account_number
@balance = 0
end
# Explicit setter as extra behavior is required
def account_number=(account_number)
puts 'Enter administrator override'
if gets == @@adiministrator_password
@account_number = account_number
else
puts 'Sorry. Incorrect password. Account number not changed'
end
end
# Explicit getter as extra behavior is required
def balance
"$#{@balance / 100}.#{@balance % 100}"
end
# Check if account has sufficient funds to complete transaction
def sufficient_funds? (withdrawal_amount)
withdrawal_amount <= @balance
end
# Destructive method
def donate_all_money!
@balance = 0
end
end
end

View file

@ -0,0 +1 @@
Dim dblDistance as Double

View file

@ -0,0 +1,5 @@
Dim iRow as Integer, iColumn as Integer
Dim sName as String
Dim nPopulation as Long
Dim xLightYear as Double
iRow = iRow + 1

View file

@ -0,0 +1,6 @@
txtTraduc.Width = iWidth
cmdSolution.Enabled = False
mnuAleatoire.Checked = False
frmScore.Show vbModal
picFace.Visible = False
picFace.Picture = LoadPicture(sFileName)

View file

@ -0,0 +1,3 @@
mnuQuit_Click()
cmdSolution_Click()
frmScore_Resize()

View file

@ -0,0 +1,43 @@
const namespace_name = @import("dir_name/file_name.zig");
const TypeName = @import("dir_name/TypeName.zig");
var global_var: i32 = undefined;
const const_name = 42;
const primitive_type_alias = f32;
const string_alias = []u8;
const StructName = struct {
field: i32,
};
const StructAlias = StructName;
fn functionName(param_name: TypeName) void {
var functionPointer = functionName;
functionPointer();
functionPointer = otherFunction;
functionPointer();
}
const functionAlias = functionName;
fn ListTemplateFunction(comptime ChildType: type, comptime fixed_size: usize) type {
return List(ChildType, fixed_size);
}
fn ShortList(comptime T: type, comptime n: usize) type {
return struct {
field_name: [n]T,
fn methodName() void {}
};
}
// The word XML loses its casing when used in Zig identifiers.
const xml_document =
\\<?xml version="1.0" encoding="UTF-8"?>
\\<document>
\\</document>
;
const XmlParser = struct {
field: i32,
};
// The initials BE (Big Endian) are just another word in Zig identifier names.
fn readU32Be() u32 {}