Changes to pldb.io

Shahriar Heidrich
Shahriar Heidrich
2 days ago
Apply Static Typing feature to more languages
concepts/bash.scroll
Changed around line 98: hasNamedArguments false
+ hasStaticTyping false
concepts/c.scroll
Changed around line 199: hasImports true
+ hasStaticTyping true
concepts/cpp.scroll
Changed around line 227: hasVirtualFunctions true
+ hasStaticTyping true
concepts/haskell.scroll
Changed around line 82: hasRunTimeGuards true
+ hasStaticTyping true
concepts/java.scroll
Changed around line 129: hasGenerics true
+ hasStaticTyping true
concepts/javascript.scroll
Changed around line 263: hasSwitch true
+ hasStaticTyping false
concepts/kotlin.scroll
Changed around line 121: hasMacros false
+ hasStaticTyping true
concepts/ocaml.scroll
Changed around line 68: hasComments true
+ hasStaticTyping true
concepts/python.scroll
Changed around line 107: canWriteToDisk true
+ hasTypeAnnotations true
+ name: str
+ hasStaticTyping true
+ # Optional, checkable using external type checkers like Mypy or Pyright
+ def print_repeated(text: str, repetitions: int) -> None:
+ print("\n".join([text]*repetitions))
+
+ print_repeated("Hello!", 10)
+ print_repeated("This won't typecheck...", "not an integer")
concepts/rust.scroll
Changed around line 172: hasPrintDebugging true
+ hasStaticTyping true
concepts/scala.scroll
Changed around line 129: hasImplicitArguments true
+ hasStaticTyping true
Breck Yunits
Breck Yunits
2 days ago
updated concepts/cycl.scroll
concepts/cycl.scroll
Changed around line 3
+ creators Doug Lenat
Shahriar Heidrich
Shahriar Heidrich
2 days ago
Add Structural Typing feature
code/measures.parsers
Changed around line 1622: hasStructsParser
+ hasStructuralTypingParser
+ extends abstractFeatureParser
+ description Does the language feature (significant) structural typing?
+ string title Structural Typing
+ string reference https://en.wikipedia.org/wiki/Structural_type_system
+
concepts/bash.scroll
Changed around line 98: hasNamedArguments false
+ hasStructuralTyping false
concepts/c.scroll
Changed around line 199: hasImports true
+ hasStructuralTyping false
concepts/cpp.scroll
Changed around line 227: hasVirtualFunctions true
- hasTypeClasses true
+ hasStructuralTyping true
+ // concepts use structural typing:
- // NOTE that in contrast to other typeclass-supporting languages,
- // concept (= typeclass) implementations
- // a) MUST be defined BEFORE the concept is introduced and
- // b) do not reference the concept directly, because the association
- // is structural, not nominal.
+ // NOTE that concept implementations MUST be defined BEFORE the concept itself
Changed around line 252: hasTypeClasses true
+ hasTypeClasses false
concepts/java.scroll
Changed around line 129: hasGenerics true
+ hasStructuralTyping false
+ https://stackoverflow.com/q/44484287
concepts/javascript.scroll
Changed around line 263: hasSwitch true
+ hasStructuralTyping false
concepts/kotlin.scroll
Changed around line 121: hasMacros false
+ hasStructuralTyping false
+ https://youtrack.jetbrains.com/issue/KT-218
concepts/ocaml.scroll
Changed around line 68: hasComments true
+ hasStructuralTyping true
concepts/python.scroll
Changed around line 107: canWriteToDisk true
+ hasStructuralTyping true
+ # Python's optional static type system features 2 kinds of structural types:
+ from typing import Protocol
+
+ class Clearable(Protocol):
+ def clear(self): ...
+
+ def print_and_clear(x: Clearable):
+ print(x)
+ x.clear()
+
+ print_and_clear([1, 2, 3]) # OK because lists have a clear() method
+ print_and_clear({1, 2, 3}) # OK because sets have a clear() method
+ print_and_clear(1) # not OK because ints don't have a clear() method
+
+ from typing import TypedDict
+
+ class NameDict(TypedDict):
+ first_name: str
+ last_name: str
+
+ class EmployeeDict(TypedDict):
+ employee_id: int
+ first_name: str
+ last_name: str
+
+ def greet(name: NameDict):
+ print(f"Hello {name['first_name']} {name['last_name']}!")
+
+ john: EmployeeDict = {
+ "first_name": "John", "last_name": "Smith", "employee_id": 123
+ }
+
+ # EmployeeDict is a (structural) subtype of NameDict even though there is no
+ # explicit relation between them, so this passes type checking:
+ greet(john)
concepts/rust.scroll
Changed around line 172: hasPrintDebugging true
+ hasStructuralTyping false
+ tuples can be seen as structural, [1] but other fundamental types like structs
+ and traits are not structural and don't have structural analogues
+
+ [1]: https://doc.rust-lang.org/reference/types/tuple.html
concepts/scala.scroll
Changed around line 129: hasImplicitArguments true
+ hasStructuralTyping true
+ // https://docs.scala-lang.org/scala3/reference/changed-features/structural-types.html#using-java-reflection-1
+ import scala.reflect.Selectable.reflectiveSelectable
+
+ type Reversable[T] = { def reverse: T }
+
+ def printReversed[T](x: Reversable[T]): Unit = {
+ println(x.reverse)
+ }
+
+ printReversed("abc")
+ printReversed(Array(1, 2, 3))
+ printReversed(1) // Doesn't compile because integers don't have a reverse method
concepts/typescript.scroll
Changed around line 154: hasPrintDebugging true
+ hasStructuralTyping true
+ // https://www.typescriptlang.org/docs/handbook/type-compatibility.html
+ // Subtype relations are structural for both interfaces and classes.
+ // Interface example:
+ interface CanCheckIncludes {
+ includes(x: T): boolean;
+ }
+
+ function logIfIncludes(includer: CanCheckIncludes, includee: T) {
+ if (includer.includes(includee)) {
+ console.log(includer);
+ }
+ }
+
+ logIfIncludes("abc", "b");
+ logIfIncludes([1, 2, 3], 4);
+ logIfIncludes(1, 1); // Fails typechecking, as numbers don't have includes()
Breck Yunits
Breck Yunits
3 days ago
updated concepts/haskell.scroll
concepts/haskell.scroll
Changed around line 146: hasTypeInference true
- - A comment
- hasFunctionOverloading TODO
+ hasFunctionOverloading false
Breck Yunits
Breck Yunits
3 days ago
updated concepts/curry.scroll
concepts/curry.scroll
Changed around line 5: name Curry
+ website https://www.curry-lang.org/
+ webRepl https://smap.curry-lang.org/smap.cgi?upload?lang=Curry&program=%2D%2D+Returns+the+last+number+of+a+list%2E%0Alast+%3A%3A+%5BInt%5D+%2D%3E+Int%0Alast+%28%5F+%2B%2B+%5Bx%5D%29+%3D+x%0A%0A%2D%2D+Returns+some+permutation+of+a+list%2E%0Aperm+%3A%3A+%5Ba%5D+%2D%3E+%5Ba%5D%0Aperm+%5B%5D+++++%3D+%5B%5D%0Aperm+%28x%3Axs%29+%3D+insert+%28perm+xs%29%0A+where+insert+ys+++++%3D+x+%3A+ys%0A+++++++insert+%28y%3Ays%29+%3D+y+%3A+insert+ys%0A+++++++%0Amain+%3D+perm+%22XYZ%22
+ description Curry is a declarative multi-paradigm programming language which combines in a seamless way features from functional programming (nested expressions, higher-order functions, strong typing, lazy evaluation) and logic programming (non-determinism, built-in search, free variables, partial data structures). Compared to the single programming paradigms, Curry provides additional features, like optimal evaluation for logic-oriented computations and flexible, non-deterministic pattern matching with user-defined functions.
+ emailList https://www.curry-lang.org/various/mailinglist/
Breck Yunits
Breck Yunits
3 days ago
updated concepts/lean.scroll
concepts/lean.scroll
Changed around line 7: creators Leonardo de Moura
+ webRepl https://live.lean-lang.org/
Shahriar Heidrich
Shahriar Heidrich
3 days ago
Add Named Arguments feature
code/measures.parsers
Changed around line 1361: hasMultipleInheritanceParser
+ hasNamedArgumentsParser
+ extends abstractFeatureParser
+ description Does the language have named arguments / named parameters?
+ string title Named Arguments
+ string reference https://en.wikipedia.org/wiki/Named_parameter
+
concepts/bash.scroll
Changed around line 93: hasImports true
+ hasFunctionOverloading false
+ hasNamedArguments false
concepts/c.scroll
Changed around line 253: hasConstants true
+ hasFunctions true
+ hasFunctionOverloading false
+ hasNamedArguments false
concepts/cpp.scroll
Changed around line 176: hasFunctionOverloading true
+ hasNamedArguments false
concepts/haskell.scroll
Changed around line 145: hasCaseInsensitiveIdentifiers false
- - A comment
+ hasFunctions true
+ hasFunctionOverloading TODO
+ hasNamedArguments false
concepts/java.scroll
Changed around line 134: hasPointers false
+ hasFunctions true
+ TODO
+ hasFunctionOverloading true
+ hasNamedArguments false
concepts/javascript.scroll
Changed around line 238: hasAnonymousFunctions true
+ hasNamedArguments false
+ // idiomatically emulated using parameters that expect objects
concepts/kotlin.scroll
Changed around line 137: hasClasses true
+ hasFunctionOverloading true
+ hasNamedArguments true
+ "abcdef".subSequence(startIndex=2, endIndex=4)
concepts/python.scroll
Changed around line 265: hasPrintDebugging true
+ hasFunctionOverloading false
+ may be simulated using `**kwargs` or `functools.singledispatch`
+ hasNamedArguments true
+ print("Hello", end="!\n")
+
+ # details: any parameter that hasn't been explicitly marked as positional-only
+ # can be provided as a named argument
concepts/ruby.scroll
Changed around line 135: hasExceptions true
+ hasNamedArguments true
+ String.new("abc", encoding: "utf-8", capacity: 16)
+
+ # details: when defining a method, parameters are positional-only by default,
+ # but can be made keyword parameters (i.e. named) by appending a colon (:),
+ # optionally followed by a default value:
+ def greet(name, time_of_day:, location: "our great city")
+ puts "Hello this fine #{time_of_day} in #{location}, #{name}!"
+ end
concepts/rust.scroll
Changed around line 199: hasWhileLoops true
+ hasFunctions true
+ hasFunctionOverloading false
+ hasNamedArguments false
concepts/scala.scroll
Changed around line 157: hasWhileLoops true
+ hasFunctionOverloading false
+ hasNamedArguments true
+ "abcdef".slice(from=2, until=4)
concepts/typescript.scroll
Changed around line 128: hasMixins true
+ hasNamedArguments false
+ // idiomatically emulated using parameters that expect objects
Breck Yunits
Breck Yunits
3 days ago
code/measures.parsers
Changed around line 2363: tagsParser
+ atoms measureNameAtom tagAtom
Breck Yunits
Breck Yunits
3 days ago
updated concepts/black.scroll
concepts/black.scroll
Changed around line 26: example
-
- (lambda (exp env cont)
- (cond ((eq? (car exp) 'instr)
- (eval-instr (car (cdr exp)) env cont))
- (else
- (original-eval-application exp env cont))))))
+ (lambda (exp env cont)
+ (cond ((eq? (car exp) 'instr)
+ (eval-instr (car (cdr exp)) env cont))
+ (else
+ (original-eval-application exp env cont))))))
Breck Yunits
Breck Yunits
4 days ago
updated concepts/peng.scroll
concepts/peng.scroll
Changed around line 13: related drs
+
+ example
+ [drs([A, B, C],
+ [theta(A, theme, C)#[1],
+ event(A, working)#[1],
+ theta(A, location, B)#[1],
+ named(B, macquarie university)#[1, [third, sg, neut],
+ [’Macquarie’,’University’]],
+ named(C, david miller)#[1, [third, sg, masc],[’David’,’Miller’]]])]