develooper Front page | perl.perl6.users | Postings from September 2018

Re: .kv ?

Thread Previous | Thread Next
September 16, 2018 08:33
Re: .kv ?
Message ID:
On 09/15/2018 03:16 PM, Brad Gilbert wrote:
> Anyway I edited the Option Types post.

Hi Brad,

I like it!  That took some thinking.  You kicked it!

      To designate that it must have a defined value assigned to
      it (not be in the null state), use the :D "smiley" designation.

      It is also possible to designate that it must always be a
      null using the :U "smiley".

That `:U` thing comes in handy with NativeCall, where a totally
blank variable is required on the input.


sub GetXDisplay () is export {
     reference: man XDisplayName
     char *XDisplayName(char *string);
     sub display-name(Str:D $name) is native('X11') is 
symbol("XDisplayName") { * }

         The XDisplayName() function returns the name of the display 
that XOpenDisplay()
         would attempt to use. If a NULL string is specified, 
XDisplayName() looks in the
         environment for the display and returns the display name that 
XOpenDisplay() would
         attempt to use. This makes it easier to report to the user 
precisely which display
         the program attempted to open when the initial connection 
attempt failed.

    my $Display;
    my $NullStr; # Do not initialize this guy!

    # char *XDisplayName(char *string);
    sub XDisplayName(Str:D $name) is native('X11') returns Str { * };

    $Display = XDisplayName( $NullStr );
    return $Display;

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About