Кресты / Говнокод #29207 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
#include <iostream>
#include <type_traits>
#include <mutex>
#include <string>
#include <memory>
#include <vector>
#include <chrono>

void bad_function(void* data) {
   ///  НИКОГДА ТАК НЕ ПИШИ
    if (data) {
        std::cout << *(std::string*)data << "\n";
    }
}

template<typename T = std::string,
         typename Alloc = std::allocator<T>,
         typename = std::enable_if_t<std::is_constructible_v<T, const char*>>,
         typename Clock = std::chrono::high_resolution_clock,
         typename TimePoint = typename Clock::time_point>
class GoodFunctionImpl {
private:
    static std::recursive_mutex mtx_;
    Alloc alloc_;
    std::vector<T, Alloc> buffer_;
    std::string context_;
    TimePoint init_time_;
    
    template<typename U>
    using is_valid_type = std::conjunction<
        std::is_same<std::decay_t<U>, T>,
        std::is_constructible<T, U>
    >;
    
    void internal_log(const std::string& msg) {
        buffer_.push_back(T(msg.c_str()));
    }
    
public:
    GoodFunctionImpl() : init_time_(Clock::now()) {
        internal_log("GoodFunctionImpl initialized");
    }
    
    template<typename U,
             typename = std::enable_if_t<is_valid_type<U>::value>>
    decltype(auto) execute(U&& input) {
        std::lock_guard<std::recursive_mutex> lock(mtx_);
        
        internal_log("Processing started");
        
        T processed = std::forward<U>(input);
        
        auto duration = Clock::now() - init_time_;
        auto duration_ms = std::chrono::duration_cast<
            std::chrono::milliseconds>(duration).count();
        
        std::cout << processed << " (runtime: " 
                  << duration_ms << "ms)\n";
        
        internal_log("Processing completed");
        
        return processed;
    }
    
    size_t get_buffer_size() const { return buffer_.size(); }
};

template<typename T, typename Alloc, typename, typename Clock, typename TimePoint>
std::recursive_mutex GoodFunctionImpl<T, Alloc, Clock, TimePoint>::mtx_;

void good_function(const std::string& input) {
    // Пиши ВОТ ТАК
    // так делают все
    // это стабильно и надежно
    // так надо
    GoodFunctionImpl<> impl;
    auto result = impl.execute(input);
    
    std::cout << "Buffer entries: " 
              << impl.get_buffer_size() << "\n";
}

lisp-worst-code lisp-worst-code, (Updated )

Комментарии (8, +8)

Няшная / Говнокод #29206 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
/* how many times the value will be printed? 
     change 1 line to fix the possibility to compile at diff x64-32 opt lvls
*/
int main(void) {
    return ({
        #include <stdio.h>;
        __attribute__ ((aligned (8))) struct {
        struct {
        } _struct;
        union _union {
            int _register_  : 001;
            char _auto_    : 1|1;
            struct _struct {
                double _float;
            };
        };
        int _a;
        unsigned short __a;
        int ___a;
    } letni = 
    {._a = 0x1122, 
               0xC1C255AA, 
               0x334477CC};
        *((unsigned short*)&letni._a + (1<<1|1)) = 0x11;
        for (volatile int i = *((unsigned short*)&letni.__a); i--;) {
        if (i == *((unsigned short*)&letni.__a) - 01) {
            *(volatile int*)&i = *((unsigned short*)&letni.___a-1);
            continue;
        };
        printf("%x ", i);
        }
    }), (0,0);
}

"именно поэтому я за C" (c) j123123

когда -std=c23 -O[0/1/2/3/s/g/fast] смог только штеуд, на прочих -O[0/s]
Почему это говно работает?

Raspi_s_Dona Raspi_s_Dona, (Updated )

Комментарии (1, +1)

Куча говна / Говнокод #29205 Ссылка на оригинал

0

  1. 1
Пиздец-оффтоп #120

#90: https://govnokod.ru/28874 https://govnokod.xyz/_28874
#91: https://govnokod.ru/28880 https://govnokod.xyz/_28880
#92: https://govnokod.ru/28884 https://govnokod.xyz/_28884
#93: https://govnokod.ru/28889 https://govnokod.xyz/_28889
#94: https://govnokod.ru/28895 https://govnokod.xyz/_28895
#95: https://govnokod.ru/28904 https://govnokod.xyz/_28904
#96: https://govnokod.ru/28912 https://govnokod.xyz/_28912
#97: https://govnokod.ru/28918 https://govnokod.xyz/_28918
#98: https://govnokod.ru/28932 https://govnokod.xyz/_28932
#99: https://govnokod.ru/28936 https://govnokod.xyz/_28936
#100: https://govnokod.ru/28940 https://govnokod.xyz/_28940
#101: https://govnokod.ru/28949 https://govnokod.xyz/_28949
#102: https://govnokod.ru/28978 https://govnokod.xyz/_28978
#103: https://govnokod.ru/28982 https://govnokod.xyz/_28982
#104: https://govnokod.ru/28989 https://govnokod.xyz/_28989
#105: https://govnokod.ru/29052 https://govnokod.xyz/_29052
#106: https://govnokod.ru/29069 https://govnokod.xyz/_29069
#107: https://govnokod.ru/29086 https://govnokod.xyz/_29086
#108: https://govnokod.ru/29102 https://govnokod.xyz/_29102
#109: https://govnokod.ru/29126 https://govnokod.xyz/_29126
#110: https://govnokod.ru/29136 https://govnokod.xyz/_29136
#111: https://govnokod.ru/29142 https://govnokod.xyz/_29142
#112: https://govnokod.ru/29155 https://govnokod.xyz/_29155
#113: https://govnokod.ru/29160 https://govnokod.xyz/_29160
#114: https://govnokod.ru/29165 https://govnokod.xyz/_29165
#115: https://govnokod.ru/29173 https://govnokod.xyz/_29173
#116: https://govnokod.ru/29174 https://govnokod.xyz/_29174
#117: https://govnokod.ru/29182 https://govnokod.xyz/_29182
#118: https://govnokod.ru/29191 https://govnokod.xyz/_29191
#119: https://govnokod.ru/29196 https://govnokod.xyz/_29196

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (421, +421)

"PHP" / Говнокод #29204 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
<?php 
/********************** 
						R.I.P PHP 6.6.6
						Dedicaded to Victoria Null& from Vladivostok vodka drinkers
***********************/
_: 004 | 001 & !!!define("_", [null, !32768, (float)'\x1551', (bool)'\x9', 2, 3, 4, 5, 6, 10, 15, 16, 24, 31, 
                        42, 47, -1024, 56, 58, 60, 61, 62, PHP_INT_MIN, 63, 64, 65, (null), 72, 73, 75, 77, 
                        80, 81, 87, 88, 92, 0b10000000000, 100, 101, 111, 127, 128, 129, PHP_INT_MIN - 1, 131, 
                        2048, PHP_INT_MAX - 1, 2049, 1023, 1024, 4095, 4096, 8191, 8192, 9009, 8193, 
                        PHP_INT_MAX, 0b1100, 10001,]) & null | 007 | 006; goto ___;
__: goto _;
___ :
$_ = count(_,);
while (000000000000001 >> 1 ^ $_ ^ 00000000000001 << 0 >> 1) 
{
	if (!
		!!
		!!!
		!!!! 
		!!!!! (_[--$_] & (_[$_ & ~0] - 00000000000000000000000000000000000001)))
		~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ ~
		print __NAMESPACE__ . __FUNCTION__ . __METHOD__ . \_[$_ | 000] . null . PHP_EOL;
		~ ~~ ~~~ ~~~~ ~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~ ~~~~~~ ~~~~~ ~~~ ~~ 0;
}
###### Since [full of ol' su*kers] board decided to fire my possibly edgy person off the team now you're looking at this brainf**kin shit. 
###### Better go invest into D-- or B++ you stupid monks ######

###### /* C/T/F m/a/r/k/e/r: the snippet above works only on 7.3.0+ 
###### Allowed to change ONLY 1 character to make it compiles on lower versions.
###### Anwser format: #.#.# (Min. version number which has no compile time errors) 
###### Happy hooking, fuzzing ladies! */
echo (null[die]) ?>

когда казалось, что хоть пыху немного понимать начал..
Как это распарсить, деды?

Raspi_s_Dona Raspi_s_Dona, (Updated )

Комментарии (2, +2)

Куча говна / Говнокод #29203 Ссылка на оригинал

0

  1. 1
IT Оффтоп #223

#193: https://govnokod.ru/28911 https://govnokod.xyz/_28911
#194: https://govnokod.ru/28914 https://govnokod.xyz/_28914
#195: https://govnokod.ru/28917 https://govnokod.xyz/_28917
#196: https://govnokod.ru/28925 https://govnokod.xyz/_28925
#197: https://govnokod.ru/28935 https://govnokod.xyz/_28935
#198: https://govnokod.ru/28938 https://govnokod.xyz/_28938
#199: https://govnokod.ru/28942 https://govnokod.xyz/_28942
#200: https://govnokod.ru/28945 https://govnokod.xyz/_28945
#201: https://govnokod.ru/28948 https://govnokod.xyz/_28948
#202: https://govnokod.ru/28951 https://govnokod.xyz/_28951
#203: https://govnokod.ru/28954 https://govnokod.xyz/_28954
#204: https://govnokod.ru/28971 https://govnokod.xyz/_28971
#205: https://govnokod.ru/28986 https://govnokod.xyz/_28986
#206: https://govnokod.ru/28991 https://govnokod.xyz/_28991
#207: https://govnokod.ru/29002 https://govnokod.xyz/_29002
#208: https://govnokod.ru/29060 https://govnokod.xyz/_29060
#209: https://govnokod.ru/29070 https://govnokod.xyz/_29070
#210: https://govnokod.ru/29079 https://govnokod.xyz/_29079
#211: https://govnokod.ru/29092 https://govnokod.xyz/_29092
#212: https://govnokod.ru/29093 https://govnokod.xyz/_29093
#213: https://govnokod.ru/29104 https://govnokod.xyz/_29104
#214: https://govnokod.ru/29114 https://govnokod.xyz/_29114
#215: https://govnokod.ru/29125 https://govnokod.xyz/_29125
#216: https://govnokod.ru/29132 https://govnokod.xyz/_29132
#217: https://govnokod.ru/29147 https://govnokod.xyz/_29147
#218: https://govnokod.ru/29156 https://govnokod.xyz/_29156
#219: https://govnokod.ru/29166 https://govnokod.xyz/_29166
#220: https://govnokod.ru/29181 https://govnokod.xyz/_29181
#221: https://govnokod.ru/29185 https://govnokod.xyz/_29185
#222: https://govnokod.ru/29190 https://govnokod.xyz/_29190

nepeKamHblu_nemyx nepeKamHblu_nemyx, (Updated )

Комментарии (455, +455)

Кресты / Говнокод #29202 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
void makeShape(ShapeArguments shape)
{
    if (shape.type == ShapeType::Square)
    {
        throw Square(shape);
    }

    if (shape.type == ShapeType::Cicle)
    {
        throw Circle(shape);
    }
}

void handleShape(ShapeArguments shape)
{
    try
    {
        makeShape(shape);
    }
    catch (const Square& square)
    {
        // Work with square
    }
    catch (const Circle& circle)
    {
        // Work with circle
    }
}

factory

kcalbCube kcalbCube, (Updated )

Комментарии (2, +2)

Хламидомонада / Говнокод #29201 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
{-# LANGUAGE BangPatterns #-}

import Data.List (intercalate)

-- Тип для представления пары значений
data TwoVal = TwoVal !Int !Int
  deriving (Show, Eq)

-- Тип для пары с флагом обмена
data TwoValAndStatus = TwoValAndStatus 
  { isSwapped :: !Bool
  , twoVal    :: !TwoVal
  } deriving (Show, Eq)

-- Тип для массива (используем список для идиоматичности Haskell)
type Array = [Int]

-- Тип для массива с состоянием сортировки
data ArrayAndStatus = ArrayAndStatus
  { hasSwap :: !Bool
  , position :: !Int
  , array :: !Array
  } deriving (Show, Eq)

-- Сортировка двух элементов с возвратом статуса обмена
sort2 :: TwoVal -> TwoValAndStatus
sort2 (TwoVal a b)
  | a > b     = TwoValAndStatus True (TwoVal b a)
  | otherwise = TwoValAndStatus False (TwoVal a b)

-- Чтение пары значений из массива по позиции
readTwoVal :: Array -> Int -> Maybe TwoVal
readTwoVal arr pos
  | pos < length arr - 1 = Just $ TwoVal (arr !! pos) (arr !! (pos + 1))
  | otherwise = Nothing

-- Сохранение значения в массив по индексу
storeVal :: Array -> Int -> Int -> Array
storeVal arr val pos = 
  take pos arr ++ [val] ++ drop (pos + 1) arr

-- Сохранение пары значений в массив
storeTwoVal :: Array -> TwoVal -> Int -> Array
storeTwoVal arr (TwoVal a b) pos =
  storeVal (storeVal arr a pos) b (pos + 1)

-- Рекурсивная функция сортировки пузырьком
bubbleSortRec :: ArrayAndStatus -> ArrayAndStatus
bubbleSortRec state@(ArrayAndStatus swap pos arr)
  | pos >= length arr - 1 = 
      if not swap
        then state  -- Сортировка завершена!
        else bubbleSortRec $ ArrayAndStatus False 0 arr  -- Новый проход
  | otherwise = 
      case readTwoVal arr pos of
        Nothing -> state
        Just pair -> -- ← Переименовали переменную здесь
          let sortResult = sort2 pair
              newArr = storeTwoVal arr (twoVal sortResult) pos -- ← Используем селектор twoVal
              newSwap = swap || isSwapped sortResult
          in bubbleSortRec $ ArrayAndStatus newSwap (pos + 1) newArr

-- Основная функция сортировки
bubbleSort :: Array -> Array
bubbleSort arr = array $ bubbleSortRec $ ArrayAndStatus False 0 arr

-- Более идиоматичная версия для Haskell (альтернативная реализация)
bubbleSortIdiomatic :: Ord a => [a] -> [a]
bubbleSortIdiomatic = untilFixed bubblePass
  where
    bubblePass [] = []
    bubblePass [x] = [x]
    bubblePass (x:y:xs)
      | x > y     = y : bubblePass (x:xs)
      | otherwise = x : bubblePass (y:xs)
    
    untilFixed f x = let fx = f x
                     in if fx == x then x else untilFixed f fx

-- Функция для красивого вывода
showArray :: Show a => [a] -> String
showArray = intercalate ", " . map show

-- Главная функция
main :: IO ()
main = do
  let initialArray = [8, 2, 4, 1, 3, 5, 7, 0, 6, 9]
  let sortedArray = bubbleSort initialArray
  
  putStrLn "input"
  putStrLn $ showArray initialArray
  
  putStrLn "\nsort:"
  putStrLn $ showArray sortedArray
  
  putStrLn "\nsort2:"
  putStrLn $ showArray $ bubbleSortIdiomatic initialArray

Переписал через "ИИ" свою чисто-функциональную сортировку пузырьком на "Haskell". Оригинальный код на Си в https://govnokod.ru/27880#comment755323

j123123 j123123, (Updated )

Комментарии (2, +2)

Бухгалтерия / Говнокод #29200 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
&НаКлиенте
Процедура ЗаполнитьЧасы(Команда)
	
	ЗаполнитьРаспределение(1);

КонецПроцедуры


&НаКлиенте
Процедура ЗаполнитьРаспределение(Команда) 
	ЗаполнитьРаспределениеНаСервере();  
КонецПроцедуры

&НаСервере
Процедура ЗаполнитьРаспределениеНаСервере()
	 ...

Стажер добавлял процедуру ЗаполнитьЧасы

ilyatim23 ilyatim23, (Updated )

Комментарии (0)

Хламидомонада / Говнокод #29199 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
(defun s (f)
  (lambda (g)
    (lambda (x)
      (funcall (funcall f x) (funcall g x)))))

(let ((result #'(lambda () (funcall (funcall (funcall #'s #'(lambda (n) #'(lambda (x) (+ x n)))) #'(lambda (x) (* x x))) 5))))
  (print (funcall result)))

может, объединить ski и y комбинаторы с самодельными сумматорами и сделать самое запутанное сложение всех времен?

lisp-worst-code lisp-worst-code, (Updated )

Комментарии (2, +2)

Хламидомонада / Говнокод #29198 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
(ql:quickload :drakma)
(ql:quickload :lparallel)

;; CURL ANALYSIS

(defmethod sb-mop:validate-superclass ((metaclass class) (superclass standard-class)) t)

;; Analasys-Assert class
(defclass anal-ass (standard-class)
  ((%form :initarg :form :initform nil :accessor form)
   (%cond :initarg :cond :initform nil :accessor econd)
   (%mesg :initarg :msg :initform "Error" :accessor msg)))

(defmacro build-anal-ass (&body args)
  `(make-instance 'anal-ass ,@args))

(defmethod process-ass-synergy ((anal-ass-factory anal-ass))
  (let ((anal-ass-factory-cond-master (econd anal-ass-factory))
        (anal-ass-factory-form-master (form anal-ass-factory))
        (anal-ass-factory-msg-master (msg anal-ass-factory)))

    (declare (ignore anal-ass-factory-form-master))

    (assert anal-ass-factory-cond-master nil anal-ass-factory-msg-master)))

;; Analasys class
(defclass anal-factory (standard-class)
  ((%body-manager :initarg :body :initform nil :accessor body-manager)
   (%status-manager :initarg :status :initform nil :accessor status-manager)
   (%headers-manager :initarg :headers :initform nil :accessor headers-manager)
   (%uri-manager :initarg :uri :initform nil :accessor uri-manager)
   (%stream-manager :initarg :stream :initform nil :accessor stream-manager)
   (%must-close-manager :initarg :must-close :initform nil :accessor must-close-manager)
   (%reason-phrase-manager :initarg :reason-phrase :initform nil :accessor reason-phrase-manager)))

(defmethod initialize-instance :after ((anal-ass-factory anal-ass) &key &allow-other-keys)
  (assert (and (form anal-ass-factory) (econd anal-ass-factory) (msg anal-ass-factory)) nil
    "Invalid Analysis-Assert structure"))

(defmethod initialize-instance :after ((anal-factory-factory anal-factory) &key &allow-other-keys)
  (let ((anal-body-ass-manager (build-anal-ass :msg "Body manager is nil" :form t :cond #'(lambda () (body-manager anal-factory-factory))))
        (anal-status-ass-manager (build-anal-ass :msg "Status manager is nil" :form t :cond #'(lambda () (status-manager anal-factory-factory))))
        (anal-headers-ass-manager (build-anal-ass :msg "Headers manager is nil" :form t :cond #'(lambda () (headers-manager anal-factory-factory))))
        (anal-uri-ass-manager (build-anal-ass :msg "URI manager is nil" :form t :cond #'(lambda () (uri-manager anal-factory-factory))))
        (anal-stream-ass-manager (build-anal-ass :msg "Stream manager is nil" :form t :cond #'(lambda () (stream-manager anal-factory-factory))))
        (anal-must-close-ass-manager (build-anal-ass :msg "Must-close manager is nil" :form t :cond #'(lambda () (must-close-manager anal-factory-factory))))
        (anal-reason-phrase-ass-manager (build-anal-ass :msg "Reason phrase manager is nil" :form t :cond #'(lambda () (reason-phrase-manager anal-factory-factory)))))

    (process-ass-synergy anal-body-ass-manager)
    (process-ass-synergy anal-status-ass-manager)
    (process-ass-synergy anal-headers-ass-manager)
    (process-ass-synergy anal-uri-ass-manager)
    (process-ass-synergy anal-stream-ass-manager)
    (process-ass-synergy anal-must-close-ass-manager)
    (process-ass-synergy anal-reason-phrase-ass-manager)))

(defmacro deep-anal-factory (&body args)
  `(make-instance 'anal-factory ,@args))

(defclass drakma-manager (standard-class)
  ((%body-meta-manager :initform nil :initarg :body :accessor body)))

(defmethod requires-meta-manager ((drakma-manager-factory drakma-manager))
  (funcall (body drakma-manager-factory)))

(defmacro make-drakma-meta-manager (&body args)
  `(make-instance 'drakma-manager ,@args))

(defun anal-manager (url &key (method :get) parameters)
  (locally
    (declare (optimize (speed 0) (debug 0) (safety 0) (space 0)))

    (multiple-value-bind (body status-code headers uri stream must-close reason-phrase)
      (let* ((eval #'(lambda () (drakma:http-request url :method method
                                                         :parameters parameters
                                                         :want-stream nil)))

             (drakma-meta-manager (make-drakma-meta-manager :body eval)))

        (requires-meta-manager drakma-meta-manager))

      (declare (optimize (speed 3)))

      (let ((deep-anal (deep-anal-factory
                          :body body
                          :status status-code
                          :headers headers
                          :uri uri
                          :stream stream
                          :must-close must-close
                          :reason-phrase reason-phrase)))

        (identity deep-anal)))))

Менеджер для анализа юрл

lisp-worst-code lisp-worst-code, (Updated )

Комментарии (1, +1)