Sidef.pod 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. =encoding utf8
  2. =head1 NAME
  3. Sidef - The Sidef programming language.
  4. =head1 DESCRIPTION
  5. Sidef is a modern, high-level, general-purpose programming language, inspired by Ruby, Raku and Go.
  6. ** ** **** * ********* *********
  7. * * ** * * **** ** ** ** ** ** ** **
  8. ** ** **** *** ********* * * *
  9. ** ** ** **** * * ****** ******
  10. * * * * * * * * * **** ** ** ** ** ** **
  11. ** ** ** **** ****** ****** * *
  12. ** ** **** * * * ********* ***
  13. * * ** * * **** ** ** ** ** ** ** **
  14. ** ** **** ********* ********* *
  15. The main features of Sidef include:
  16. =over 2
  17. =item * object-oriented programming
  18. =item * functional programming
  19. =item * functional pattern matching
  20. =item * optional lazy evaluation
  21. =item * multiple dispatch
  22. =item * lexical scoping
  23. =item * lexical closures
  24. =item * keyword arguments
  25. =item * regular expressions
  26. =item * support for using Perl modules
  27. =item * optional dynamic type checking
  28. =item * big integers, rationals, floats and complex numbers
  29. =back
  30. =head1 SYNOPSIS
  31. use Sidef;
  32. my $sidef = Sidef->new(
  33. name => 'test', # name of the program
  34. opt => {}, # command-line options
  35. parser_opt => {}, # parser options
  36. );
  37. # Sidef code
  38. my $code = 'say "1 + 2 = #{1 + 2}"';
  39. # Execute the code
  40. $sidef->execute_code($code);
  41. # Compile the code to Perl
  42. my $perl = $sidef->compile_code($code, 'Perl');
  43. # Parse the Sidef code into an AST
  44. my $ast = $sidef->parse_code($code);
  45. # Optimize the AST by performing constant-folding
  46. my $oast = $sidef->optimize_ast($ast);
  47. # Compile the AST back into Sidef code
  48. print $sidef->compile_ast($oast, 'Sidef');
  49. =head1 SUBROUTINES/METHODS
  50. =head2 new
  51. my $s = Sidef->new(name => '...');
  52. Creates a new Sidef object and returns it.
  53. =head2 parse_code
  54. my $ast = $s->parse_code($code);
  55. Parses a given Sidef code and returns the AST.
  56. =head2 optimize_ast
  57. my $oast = $s->optimize_ast($ast);
  58. Performs constant-folding and some other optimizations on a given AST.
  59. Returns a new optimized AST.
  60. =head2 compile_ast
  61. my $ccode = $s->compile_ast($ast, $backend);
  62. Compiles the AST into code and returns it.
  63. Valid values for the backend are: C<'Sidef'>, C<'Perl'>.
  64. =head2 compile_code
  65. my $ccode = $s->compile_code($code, $backend)
  66. Parses and compiles the given Sidef code into target code and
  67. returns it.
  68. Valid values for the backend are: C<'Sidef'>, C<'Perl'>.
  69. =head2 execute_code
  70. my $result = $s->execute_code($code);
  71. Parses, compiles and executes a given Sidef code and returns
  72. the result of the last statement.
  73. =head2 version
  74. Sidef->version
  75. Returns the version of Sidef as a String object.
  76. =head2 numeric_version
  77. Sidef->numeric_version
  78. Returns the version of Sidef as a Number object.
  79. =head1 WWW
  80. You can find more info about Sidef, by clicking on the following links:
  81. =over 2
  82. =item * GitHub: L<https://github.com/trizen/sidef>
  83. =item * Gitbook: L<https://trizen.gitbook.io/sidef-lang/>
  84. =item * Tutorial: L<https://notabug.org/trizen/sidef/wiki>
  85. =item * RosettaCode: L<https://rosettacode.org/wiki/Sidef>
  86. =back
  87. =head1 QUESTIONS & ANSWERS
  88. Need help with Sidef? Feel free to ask questions here: L<https://github.com/trizen/sidef/discussions/categories/q-a>
  89. =head1 LICENSE AND COPYRIGHT
  90. Copyright (C) 2013-2024 Daniel Șuteu, Ioana Fălcușan
  91. This program is free software; you can redistribute it and/or modify it
  92. under the terms of the B<Artistic License (2.0)>. You may obtain a copy
  93. of the full license at:
  94. L<https://www.perlfoundation.org/artistic-license-20.html>
  95. Any use, modification, and distribution of the Standard or Modified
  96. Versions is governed by this Artistic License. By using, modifying or
  97. distributing the Package, you accept this license. Do not use, modify,
  98. or distribute the Package, if you do not accept this license.
  99. If your Modified Version has been derived from a Modified Version made
  100. by someone other than you, you are nevertheless required to ensure that
  101. your Modified Version complies with the requirements of this license.
  102. This license does not grant you the right to use any trademark, service
  103. mark, tradename, or logo of the Copyright Holder.
  104. This license includes the non-exclusive, worldwide, free-of-charge
  105. patent license to make, have made, use, offer to sell, sell, import and
  106. otherwise transfer the Package with respect to any patent claims
  107. licensable by the Copyright Holder that are necessarily infringed by the
  108. Package. If you institute patent litigation (including a cross-claim or
  109. counterclaim) against any party alleging that the Package constitutes
  110. direct or contributory patent infringement, then this Artistic License
  111. to you shall terminate on the date that such litigation is filed.
  112. Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
  113. AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  114. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  115. PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
  116. YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
  117. CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
  118. CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
  119. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  120. =cut