128 points · by todsacerdoti · 5y ago · 32 comments
This language has been encouraging me to ruminate on data provenance and traceability tonight.
The point is attaching meta info to values which aren't pointless. Say:
weight = 42 /* pounds */;
It's kinda like types, but without the type checks. I'm not purely sarcastic, because boxing values within objects so they have a type has drawbacks.That said, there are better way of typing values without boxing them.
/** Half the number **
*********************
** Multiplies the number by one half (0.5)
*/
float x2 = x * 0.5F;
/** Copy the number **
*********************
** Stores a copy of the number in a new variable
*/
float y = x;
/** Pointer cast **
******************
** Take the address of the number,
** cast the pointer to a pointer pointing to long,
** and dereference that pointer,
** then store the result in a new variable.
*/
long i = * ( long * ) &y;
/** Subtract and shift **
************************
** Shift the number one bit position to the right,
** then subtract the result from the constant 0x5f3759df
*/
i = 0x5f3759df - ( i >> 1 );
/** Pointer cast **
******************
** Take the address of the number,
** cast the pointer to a pointer pointing to float,
** and dereference that pointer,
** then store the result in an existing variable.
*/
y = * ( float * ) &i;
/** Multiply twice, subtract and multiply again **
*************************************************
** Multiplies the number by itself,
** then multiplies the result by the other number,
** then subtracts that from the constant three halfs (1.5),
** then multiplies that by the number.
** The original number.
** The first number.
** You know what I mean.
*/
y = y * ( 1.5F - ( x2 * y * y ) );
/** Multiply twice, subtract and multiply again **
*************************************************
** Multiplies the number by itself,
** then multiplies the result by the other number,
** then subtracts that from the constant three halfs (1.5),
** then multiplies that by the number.
** The original number.
** The first number.
** You know what I mean.
** This can be removed.
*/
// y = y * ( 1.5F - ( x2 * y * y ) );
/** Return from function **
**************************
** Returns the number
*/
return y;I would like to see the outcome of people trying to design a language with first-class scope.
Just to scratch my own itch, and it's stringly so I could throw it together in about 3 days.
If that is mildly interesting to you.
Which you can also see here [0], in the interpreter, or here[1] for the "let" example. Everything gets it's own scope, with only "global!" and "set!" being able to escape that. (And all the usual flow control like "if", "cond", "for", etc. are just ordinary function calls.)
[0] https://git.sr.ht/~shakna/scriptlang/tree/master/item/script...
[1] https://git.sr.ht/~shakna/scriptlang/tree/master/item/exampl...
Basically... bang on for a code jam language.
>>> print(x?) /* the number 4.0 */
Should yield
/* the number 4.0 */ /* a comment */
Right?
It's a terrible name, and even the person who came up with the name admits that it's terrible: "The word dynamic was chosen [...] because it sounded impressive."
let x = 40 + 2 /* the number fourtytwo */;
let x = 40 + 2 anno "the number fourtytwo";
let x = 40 + 2 @"the number fourtytwo";EDIT: Oh, another user pointed out the origin for it.