3 ms·
What he said. Turbo Pascal 7 a better designed language than Go, for the most part.
by flavio81 8y ago
What he said. Turbo Pascal 7 a better designed language than Go, for the most part.
- sriram_malhar 8y agoI'd like an example or two.
- pjmlp 8y agoEnumerations in Turbo Pascal type Colours = (Red, White, Blue); Enumerations in Go type Colours int const ( Red Colours = iota White Blue ) FFI in Turbo Pascal function Sin(const num: Integer): Double; external 'ext name'; FFI in Go (requires external help from a C compiler) // #include <stdio.h> // #include <errno.h> import "C" func Sin (num uint) float32 { return C.sin } Reference parameters in Turbo Pascal with null safety thanks type system procedure Swap(var a,b:Integer); var temp: Integer; begin temp:=a; a:=b; b:=temp end; Swap(x, y) Swap(nil, y) { compiler error: Got "Pointer" expected "SmallInt" } Reference parameters in Go (no type safety via type system, manual testing for nil required) func Swap (a *int, b*int) { var temp = *a *a = *b *b = temp } Swap(&x, &y) Swap(nil, &y) { runtime error: Invalid memory address or nil pointer dereference } I was also tempted to move the time scale from 1992 to 2009, but then I wouldn't be able to reproduce the generics from Object Pascal in Go. Ah, and Turbo Pascal 5.5 was compiling around 34 000 lines/minute in computers whose CPUs were maxed at about 30 MHZ, http://edn.embarcadero.com/article/20803 http://edn.embarcadero.com/article/20803
- YouAreGreat 8y agoThe way I remember it, Pascal enums were useless. Regarding nil safety, did Pascal allow something along the line of the following? var x: ^int; ... x^ := nil; Swap(x^, y)
- pjmlp 8y agoUseless to those that didn't understood how to take advantage of them. They can be used as indexes, range validation, access control in variant records to simulate sum types. Enumerations are so useless that majority of modern languages have direct support for them. Yes, it did allow your contrived example, which seldom occurred in practice because proficient Pascal programmers only used pointers when other type safe alternatives weren't possible.