[felix] #9: adding character literals

0 views
Skip to first unread message

felix

unread,
May 12, 2007, 1:30:13 AM5/12/07
to felix-...@googlegroups.com
#9: adding character literals
-------------------------+--------------------------------------------------
Reporter: erickt | Owner:
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: syntax | Version:
Keywords: |
-------------------------+--------------------------------------------------
Right now we don't have an easy way to directly create a character
literal. We have to do `char 'x'`, which is just essentially `'x'.[0]`.
Unfortunately, we're low on keywords to represent this. One option I've
run across is to do what [http://www.bitc-lang.org/docs/bitc/spec.html
bitc] does, and use `#\`''printable-character'' as a prefix to a printable
character. For non-printable characters, they're either named:

{{{
#\space
#\linefeed
#\return
#\tab
#\backspace
#\lbrace
#\rbrace
}}}

Or you could use unicode characters via a couple mechanisms, based off of
[http://docs.python.org/ref/strings.html python]'s string literals. First,
you can use numbers to look up the character value:

8-bit octal:
{{{
#\o77
}}}

8-bit hex:
{{{
#\xFF
}}}

16-bit hex:
{{{
#\uFFFF
}}}

32-bit hex:
{{{
#\UFFFFFFFF
}}}

Or you could use `\N{`''name''`}` to look up the unicode name in the
unicode database.

To deal with typing of the character, we'll add support to use the
coercing syntax. This would be used like this:

{{{
val x = #\a : char;
val x = #\a : wchar;
val x = #\a : uchar;

val x:char = #\a;
val x:wchar = #\a;
val x:uchar = #\a;
}}}

The compiler should detect if we're trying to coerce a character too large
to fit in the type requested. This should be a compile-time error:

{{{
val x = \u1234 : char;
}}}

--
Ticket URL: <http://code.felix-lang.org/ticket/9>
felix <http://code.felix-lang.org>
The advanced scripting language

felix

unread,
Mar 18, 2010, 6:29:29 PM3/18/10
to felix-...@googlegroups.com
#9: adding character literals
-------------------------+--------------------------------------------------
Reporter: erickt | Owner:
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: syntax | Version:
Keywords: |
-------------------------+--------------------------------------------------

Comment(by nikol):

Sevodnya I will tell you how I created these sites -
[http://putana015.co.cc] [http://putana016.co.cc] [http://putana017.co.cc]
[http://putana018.co.cc] but first you must go to them and click on the
tube!

--
Ticket URL: <http://code.felix-lang.org/ticket/9#comment:1>

Reply all
Reply to author
Forward
0 new messages