Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MIRROR ofhttps://codeberg.org/catseye/Cfluviurrh : A programming language for writing programs that have feelings

License

NotificationsYou must be signed in to change notification settings

catseye/Cfluviurrh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version 1.0

Cfluviurrh is, as far as I am aware, the first programming language designedfor writing programs that canfeel. Cfluviurrh defines a mechanism by whicha program can be instructed to experience particular emotions.

You might, thus, on first blush, consider Cfluviurrh to be unimplementable,as modern-day computers are not capable of experiencing emotions (you guess.)

However, this is demonstrably untrue. There is nothing that strictly requiresa computer program to be executed entirely on an electronic computer. It issimply that, to be correctly implemented, Cfluviurrh must be implemented for asystem that we know is, in some way, capable of experiencing emotions.

For example, it could be implemented as a contractual obligation for amethod actor, or similar professional capable of feeling emotions ondemand; this individual would be required to read a program text written inCfluviurrh, and carry out its instructions, feeling the specified emotionsat the required points in the program.

Or, in the approach the reference implementation takes, an electroniccomputer may co-operate with a contractually obligated individual termedthe "emoter". The computer executes all the parts of the program which donot necessitate emotional experience, and prompts the emoter to experienceemotions on behalf of the running program when required.

Design

Program State

The state of a running Cfluviurrh program consists of an unlimited number ofregisters, each of which can contain a non-negative integer of unlimitedsize. (Of course, a particular implementation may impose its own limitshere, as we can't expect computers to be infinite [I guess.])

The registers are indexed by number, starting at zero; the first twenty-six(registers 0 to 25) also have names,a throughz. Initially, everyregister contains a zero value.

There is also a special value called theinstruction pointer (IP), whichindicates which character in the Cfluviurrh program will be executed next.As statements are executed, the IP is advanced to the next statement in theprogram text (except in the case of a jump, described below.) The IPinitially refers to the first character of the program.

There is also a special value called theemotion bank number, which isinitially zero. An implementation must implement emotion bank zero,but need not implement any other emotion banks, nor need it implementemotion bank switching. All emotion banks other than zero are undefinedand reserved for future use.

Syntax

A Cfluviurrh program text is a sequence of ASCII characters. In the courseof execution, the character at the IP is considered to be the start of thenext statement.

A statement is either:

  • whitespace (a space, tab, newline, or carriage feed character);nothing happens when this is executed, the IP is simply advancedto the next character.
  • acomment, which begins with(; the IP is advanced to onecharacter past the next) character in the program, with nothingelse happening. Comments do not nest.
  • alabel, which is a: followed by any printable character(called thelabel name). The IP is advanced to one character pastthe label name; nothing else happens.
  • aregister reference, followed by an operator. A register referenceis a lowercase letter froma toz, which refers to the registerwith the same name,or an uppercase letter fromA toZ, whichrefers to the register with the index given by the contents of theregister with the corresponding lower-case name. (So if registeracontained the number 4,A would refer to registere.)

There are several subcases for the syntax of a statement which beginswith a register reference. These are:

  • anassignment, which is where the register reference is followedby a= character, which is followed by a value. A value canbe either a register reference, in which case the value is takenfrom the register being referred to, or it may be a literaldigit from0 to9, in which case it is the value of thatdigit as an Arabic numeral. Thus,a=1,b=B, andR=4 areall valid assignment statements, but7=a is not.
  • amodifying assignment, which is where the register reference isfollowed by one of the characters+,-,*, or/, which isfollowed by a= character which is followed by a value. Theregister being referred to has the value added to it, subtractedfrom it, is multiplied by the value, or is divided (integerdivision, rounding down) by the value, respectively, based on theoperator character. Thus,a+=1,a*=2, andF/=f are allvalid modifying assignments.
  • alabel location assignment, which is where the register referenceis followed by a@ character which is followed by a= characterwhich is followed by a label name. A label with this label nameis sought in the program and, if found, the position of the labelin the program text (with 0 being the position of the first characterof the program, and with all characters, including whitespace andcomments, having sequential positions within the program) is written tothe register. If there are multiple labels with the same label name,the one closest to the start of the program text is chosen. If amatching label is not found, "an error occurs", whatever that meansexactly.
  • anoutput statement, which is where the register referenceis followed by a> character. The ASCII character with the samevalue as the contents of the register will be written to the program'soutput stream. If the value of the register is outside of the range0 to 127, "an error occurs".
  • aninput statement, which is where the register referenceis followed by a< character. An ASCII character is retrieved fromthe program's input stream, and its value is written into the register.
  • ajump statement, which is where the register reference is followedby a? character, followed by aconditional. A conditional is avalue, followed by one of the characters=,>, or<, followed bya value. A conditional, when evaluated during a program run, is eithertrue or false. A conditional has the meaning you would probablyexpect;2=2 is true,4>5 is false, andA<2 is true if thearegister contains 4 and thee register contains 1. If theconditional is true, the IP is set to the value found in the registerreferred to by the register reference; otherwise, the IP advancesas usual. Either way, an emotion is experienced (see below) everytime a jump statement is executed.
  • anemotion bank switch statement, which is where the registerreference is followed by a= followed by a>. The emotion bankis switched to the value in the register. The previous emotion banknumber is then written to the register for posterity. If that emotionbank is not supported by the implementation, "an error occurs". An"error" may also "occur" if emotion bank switching is not supportedby the implementation.

Note that whitespace and comments are not allowed inside any statementwhich begins with a register reference. If an attempt is made to execute anystatement which does not conform to the above syntax, "an error occurs".

The input stream and output stream are implementation-defined concepts.

If division by zero is attempted, "an error occurs".

If a jump is made to a position beyond the extent of the program text, eitherthe program just ends, or "an error occurs" -- implementor's choice.

Experiencing Emotions

Whenever a jump statement is executed, an emotion is experienced at a certainintensity level.

The emotion being experienced, and the intensity level, depends on thecurrently active emotion bank. Only emotion bank zero is described here.

The contents of the first twenty-six registers, at the point in time thatthe emotion is to be experienced, are summed (modulo 74) to obtain anemotion number. The emotion number refers to the following table; itis consulted to obtain the emotion to be experienced.

  • 0: sadness
  • 1: sorrow
  • 2: despair
  • 3: worry
  • 4: depression
  • 5: misery
  • 6: melancholy
  • 7: wistfulness
  • 8: disappointment
  • 9: regret
  • 10: longing
  • 11: impatience
  • 12: anger
  • 13: hostility
  • 14: rage
  • 15: hatred
  • 16: disgust
  • 17: contempt
  • 18: envy
  • 19: arrogance
  • 20: betrayal
  • 21: hurt
  • 22: grief
  • 23: remorse
  • 24: shame
  • 25: embarrassment
  • 26: guilt
  • 27: timidity
  • 28: loneliness
  • 29: annoyance
  • 30: frustration
  • 31: confusion
  • 32: shock
  • 33: angst
  • 34: anguish
  • 35: anxiety
  • 36: apathy
  • 37: vindication
  • 38: gratitude
  • 39: hope
  • 40: awe
  • 41: wonder
  • 42: surprise
  • 43: pity
  • 44: boredom
  • 45: apprehension
  • 46: distrust
  • 47: dread
  • 48: horror
  • 49: loathing
  • 50: terror
  • 51: panic
  • 52: hysteria
  • 53: pride
  • 54: anticipation
  • 55: curiosity
  • 56: boldness
  • 57: excitement
  • 58: thrill
  • 59: zeal
  • 60: enthusiasm
  • 61: calmness
  • 62: contentment
  • 63: satisfaction
  • 64: happiness
  • 65: bliss
  • 66: joy
  • 67: ecstasy
  • 68: euphoria
  • 69: admiration
  • 70: desire
  • 71: passion
  • 72: love
  • 73: lust

There are five intensity levels, listed in the following table. To find theintensity level of an emotion to be experienced, each of the first twenty-sixregisters are multiplied by three (modulo five) and this set of values issummed (modulo five.)

  • 0: faint
  • 1: mild
  • 2: moderate
  • 3: marked
  • 4: extreme

Implementation

The reference implementation of Cfluviurrh is an interpreter written inANSI C, and imposes arbitrary limits on the size of the program text, thenumber of registers, and the maximum value of each integer in a register(by default, 8000 characters, 8000 registers, and whateverint means toyour C compiler, respectively); however, these arbitrary limits should notbe taken as defining limitations on the language's execution model. It'sjust that, you know, it's C.

As mentioned, the reference implementation requires the user to agree toact as the emoter. As it uses C's standard input and standard output tointeract with the emoter, asking them to agree to act as the emoter, andprompting them to feel the required emotions, the input stream and outputstream of the Cfluviurrh program are assigned to two files given on thecommand line:

cfluviurrh <program-file> <input-file> <output-file>

To facilitate interactive Cfluviurrh programs, the input-file andoutput-file may be named pipes, or (on AmigaOS) console devices, orsomething.

When "an error occurs" the reference interpreter generally exits to theoperating system with an error message of some sort. Although, it mayjust crash, too.

Discussion

The name "Cfluviurrh" is a kind of irrational portmanteau ofcatarrhandeffluvium. I hope I'm never asked to present on it at a conference,because I'm not quite sure how to pronounce it.

The idea to design a programming language which supports the experiencing ofemotions came to me in the summer of 2011 while I was in Toronto's PearsonInternational Airport. (Let the critics who insist that YYZ has contributednothing to culture besilenced!)

It then dovetailed, about a year later, with an urge I had to design alanguage with a fairly intuitive syntax, but simple enough that writing a"real" parser would not be necessary. I implemented it in C partly because itwould be nice to port it to AmigaOS 1.3 someday, and partly because, if Idon't have enough C repos on Github to outnumber my legacy Perl repos,they'll label Cat's Eye Technologies a Perl outfit, and I don't particularlywant that.

One of the design challenges (though not, I should not, a very difficult one)was making it so that every non-trivial Cfluviurrh program experiencedsomeemotion. Tying it to the conditional jump statement solved that problem.The upshot is that "Hello, world!" feels nothing at all, while "99 bottles"or printing out the ASCII table goes through a bewildering array of emotions.

While some of the entries in the emotion table may not be emotions per se,and while some combinations of intensity and emotion, such as "faint zeal","mild rage", and "extreme apathy" may be tricky to express, this does notdetract from the bare fact that Cfluviurrhdoes support experiencingemotions.

Cfluviurrh is Turing-complete. Proof of this is left as an exercise for thereader (don't you hate it when authors say that?)

Because every label name can only be a single printable character, it mightappear that the number of jump destinations in a program is limited to 95.This is not true, as labels are only a convenience. You can load any valueyou like into a register, then jump to that position in the program text.

In fact, there is nothing stopping you from jumping inside a comment, witha label or otherwise. In fact, from this perspective, comments could besomewhat valuable control flow structures; consider

... (:A ... (:B ... () ...

Execution coming in from the left will skip this "block"; execution comingin at the:A label will skip the "inner block", and execution coming inat:B will only execute the "inner block".

Happy Cfluviurrhing! (Or sad Cfluviurrhing, or timid Cfluviurrhing, or...)
Chris Pressey
Winnipeg, Manitoba
August 26, 2012

About

MIRROR ofhttps://codeberg.org/catseye/Cfluviurrh : A programming language for writing programs that have feelings

Topics

Resources

License

Stars

Watchers

Forks

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp